#include "SeatMemoryModule.h"
#include "SeatMemoryModule_private.h"

#define SeatMemoryModule_IN_Confirm    ((uint8_T)1U)
#define SeatMemoryModule_IN_Default    ((uint8_T)2U)
#define SeatMemoryModule_IN_Fault      ((uint8_T)3U)

#define SeatMemoryModule_IN_Step1      ((uint8_T)1U)
#define SeatMemoryModule_IN_Step2      ((uint8_T)2U)
#define SeatMemoryModule_IN_Step3      ((uint8_T)3U)
#define SeatMemoryModule_IN_Step4      ((uint8_T)4U)
#define SeatMemoryModule_IN_Step5      ((uint8_T)5U)

#define SeatMemoryModule_IN_Counter    ((uint8_T)1U)

#define SeatMemoryModule_IN_Confirm1   ((uint8_T)2U)
#define SeatMemoryModule_IN_Default_k  ((uint8_T)3U)
#define SeatMemoryModule_IN_Fault_a    ((uint8_T)4U)

#define SeatMemoryMo_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
#define SeatMemoryModule_IN_Default_i  ((uint8_T)2U)
#define SeatMemoryModule_IN_NotDefault ((uint8_T)3U)
#define SeatMemory_IN_AccountChgConfirm ((uint8_T)1U)

#define SeatMemoryModule_IN_Init       ((uint8_T)1U)
#define SeatMemoryModule_IN_Update     ((uint8_T)2U)

#define SeatMemoryModule_IN_Active     ((uint8_T)1U)
#define SeatMemoryModule_IN_Cofirm     ((uint8_T)2U)
#define SeatMemoryModule_IN_Default_p  ((uint8_T)3U)

#define SeatMemoryModule_IN_Default_n  ((uint8_T)1U)
#define SeatMemoryModule_IN_MovBack    ((uint8_T)2U)
#define SeatMemoryModule_IN_MovFrwd    ((uint8_T)3U)

#define SeatMemoryModu_IN_WelcomeMvBack ((uint8_T)2U)
#define SeatMemoryModu_IN_WelcomeMvFrwd ((uint8_T)3U)
#define SeatMemoryModule_IN_MoveBack   ((uint8_T)1U)
#define SeatMemoryModule_IN_MoveEnd    ((uint8_T)2U)

uint8_T gSMM_inU8IGNSts;
uint8_T gSMM_inU8MemAccount1;
uint8_T gSMM_inU8MemAccount2;
uint8_T gSMM_inU8MemAccount3;
uint16_T gSMM_inU16Account1HallFromEE[7];
uint16_T gSMM_inU16Account2HallFromEE[7];
uint16_T gSMM_inU16Account3HallFromEE[7];
uint16_T gSMM_inU16Account0HallFromEE[7];
uint16_T gSMM_inU16DrvSeatCusQhHall;
uint16_T gSMM_inU16DrvSeatCusSzHall;
uint16_T gSMM_inU16DrvSeatBckQhHall;
boolean_T gSMM_inBlSeatMemEnSw;
uint16_T gSMM_inU16DrvMirrorQj1Hall;
uint16_T gSMM_inU16DrvMirrorQj2Hall;
uint16_T gSMM_inU16PssMirrorQj1Hall;
uint16_T gSMM_inU16PssMirrorQj2Hall;
uint16_T gSMM_InU8DrvSeatCusQhValue;
uint16_T gSMM_InU8DrvSeatCusSzValue;
uint16_T gSMM_InU8DrvSeatBckQhValue;
uint16_T gSMM_InU8DrvSeatCusQhMax;
uint16_T gSMM_InU8DrvSeatCusSzMax;
uint16_T gSMM_InU8DrvSeatBckQhMax;
uint8_T gSMM_inU8AccountApply;
boolean_T gSMM_inBlDrvDoorSts;
boolean_T gSMM_inU16VehicleSpeedVld;
uint16_T gSMM_inU16VehicleSpeed;
boolean_T gSMM_inBlReverseGearSts;
boolean_T gSMM_inBlReverseGearValid;
boolean_T gSMM_inBlDrvSeatCusQhBlock;
boolean_T gSMM_inBlDrvSeatCusSzBlock;
boolean_T gSMM_inBlDrvSeatBckQhBlock;
boolean_T gSMM_inBlDrvMirrorQj1Block;
boolean_T gSMM_inBlDrvMirrorQj2Block;
boolean_T gSMM_inBlPssMirrorQj1Block;
boolean_T gSMM_inBlPssMirrorQj2Block;
uint8_T gSMM_inU8CrashIntensity;
boolean_T gSMM_inBlSeatWelcomeEn;
uint8_T gSMM_InU8EngineRunning;
uint8_T gSMM_InU8RemoteStart;
uint8_T gSMM_InU8Ms4DriverHeatVent;
uint8_T gSMM_InU8Ms4PassengerHeatVent;
uint16_T gSMM_InU16Seat1NtcAd;
uint16_T gSMM_InU16Seat2NtcAd;
uint8_T gSMM_InU8Seat1HeatFaultDtc;
uint8_T gSMM_InU8Seat2HeatFaultDtc;
uint8_T gSMM_InU8Seat1VentFaultDtc;
uint8_T gSMM_InU8Seat2VentFaultDtc;
uint8_T gSMM_InU8TboxDriverHeat;
uint8_T gSMM_InU8TboxPassengerHeat;
uint8_T gSMM_InU8TboxDriverVent;
uint8_T gSMM_InU8TboxPassengerVent;
boolean_T gSMM_InBlCcpDriverHeat;
boolean_T gSMM_InBlCcpPassengerHeat;
boolean_T gSMM_InBlCcpDriverVent;
boolean_T gSMM_InBlCcpPassengerVent;
boolean_T gSMM_inBlBrSw;
boolean_T gSMM_inBlBfSw;
boolean_T gSMM_inBlFdSw;
boolean_T gSMM_inBlRrwSw;
boolean_T gSMM_inBlFuSw;
boolean_T gSMM_inBlFrdSw;
uint8_T gSMM_inU8MirrSlctSw;
boolean_T gSMM_inBlMirrBfSw;
boolean_T gSMM_inBlMirrBrSw;
boolean_T gSMM_inBlMirrLfSw;
boolean_T gSMM_inBlMirrRtSw;
uint16_T gSMM_OutU16Account1HallToEE[7];
uint16_T gSMM_OutU16Account2HallToEE[7];
uint16_T gSMM_OutU16Account3HallToEE[7];
uint16_T gSMM_OutU16Account0HallToEE[7];
int16_T gSMM_OutS16Seat1NtcTmp;
int16_T gSMM_OutS16Seat2NtcTmp;
uint8_T gSMM_OutU8AccountApplySts;
uint8_T gSMM_OutU8DrvSeatCusQhValue;
uint8_T gSMM_OutU8DrvSeatCusSzValue;
uint8_T gSMM_OutU8DrvSeatBckQhValue;
uint8_T gSMM_OutU8DrvSeatCusQhCmd;
uint8_T gSMM_OutU8DrvSeatCusSzCmd;
uint8_T gSMM_OutU8PssMirrorQj2Cmd;
uint8_T gSMM_OutU8DrvSeatBckQhCmd;
uint8_T gSMM_OutU8DrvMirrorQj1Cmd;
uint8_T gSMM_OutU8DrvMirrorQj2Cmd;
uint8_T gSMM_OutU8PssMirrorQj1Cmd;
uint8_T gSMM_OutBlSeatMemSwReq;
uint8_T gSMM_OutU8Seat1HeatDuty;
uint8_T gSMM_OutU8Seat2HeatDuty;
uint8_T gSMM_OutU8Seat1HeatVentSts;
uint8_T gSMM_OutU8Seat2HeatVentSts;
uint8_T gSMM_OutU8Seat1VentDuty;
uint8_T gSMM_OutU8Seat2VentDuty;
boolean_T gSMM_OutU16Account1HallToEESw;
boolean_T gSMM_OutU16Account2HallToEESw;
boolean_T gSMM_OutU16Account3HallToEESw;
boolean_T gSMM_OutU16Account0HallToEESw;
boolean_T gSMM_OutBlSeat1HeatCmd;
boolean_T gSMM_OutBlSeat2HeatCmd;
int16_T gSMM_CfgTableNtcTmp[37] = { 125, 120, 115, 110, 105, 100, 95, 90, 85, 80,
  75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15,
  -20, -25, -30, -35, -40, -45, -50, -55 } ;

uint16_T gSMM_CfgTableNtcAd[37] = { 32U, 37U, 42U, 48U, 54U, 62U, 70U, 80U, 92U,
  105U, 121U, 140U, 162U, 189U, 220U, 258U, 301U, 352U, 412U, 482U, 565U, 654U,
  758U, 875U, 1005U, 1146U, 1305U, 1466U, 1647U, 1827U, 2007U, 2181U, 2344U,
  2491U, 2621U, 2733U, 2829U } ;

uint16_T gSMM_CfgU16SeatWelcomeHallCnt = 500U;
uint8_T gSMM_CfgU8HeatHighTgtTemp = 42U;
uint8_T gSMM_CfgU8HeatLowTgtTemp = 37U;
uint8_T gSMM_CfgU8HeatMidTgtTemp = 39U;
uint8_T gSMM_CfgU8VentHighTgtDuty = 90U;
uint8_T gSMM_CfgU8VentLowTgtDuty = 66U;
uint8_T gSMM_CfgU8VentMidTgtDuty = 76U;
B_SeatMemoryModule_T SeatMemoryModule_B;
DW_SeatMemoryModule_T SeatMemoryModule_DW;
RT_MODEL_SeatMemoryModule_T SeatMemoryModule_M_;
RT_MODEL_SeatMemoryModule_T *const SeatMemoryModule_M = &SeatMemoryModule_M_;
int16_T look1_iu16lu16n16ts16D_RXQzuhbZ(uint16_T u0, const uint16_T bp0[], const
  int16_T table[], uint32_T maxIndex)
{
  int16_T y;
  uint16_T frac;
  uint32_T bpIdx;
  if (u0 <= bp0[0U]) {
    bpIdx = 0U;
    frac = 0U;
  } else if (u0 < bp0[maxIndex]) {
    for (bpIdx = maxIndex >> 1U; u0 < bp0[bpIdx]; bpIdx--) {
    }

    while (u0 >= bp0[bpIdx + 1U]) {
      bpIdx++;
    }

    frac = (uint16_T)(((uint32_T)(uint16_T)((uint32_T)u0 - bp0[bpIdx]) << 16) /
                      (uint16_T)((uint32_T)bp0[bpIdx + 1U] - bp0[bpIdx]));
  } else {
    bpIdx = maxIndex;
    frac = 0U;
  }

  if (bpIdx == maxIndex) {
    y = table[bpIdx];
  } else {
    y = (int16_T)((int16_T)(((table[bpIdx + 1U] - table[bpIdx]) * frac) >> 16) +
                  table[bpIdx]);
  }

  return y;
}

uint32_T MultiWord2uLong(const uint32_T u[])
{
  return u[0];
}

void uMultiWordShr(const uint32_T u1[], int32_T n1, uint32_T n2, uint32_T y[],
                   int32_T n)
{
  int32_T nb;
  int32_T i;
  uint32_T yi;
  uint32_T u1i;
  int32_T nc;
  uint32_T nr;
  uint32_T nl;
  int32_T i1;
  nb = (int32_T)(n2 >> 5);
  i = 0;
  if (nb < n1) {
    nc = n + nb;
    if (nc > n1) {
      nc = n1;
    }

    nr = n2 - ((uint32_T)nb << 5);
    if (nr > 0U) {
      nl = 32U - nr;
      u1i = u1[nb];
      for (i1 = nb + 1; i1 < nc; i1++) {
        yi = u1i >> nr;
        u1i = u1[i1];
        y[i] = u1i << nl | yi;
        i++;
      }

      yi = u1i >> nr;
      if (nc < n1) {
        yi |= u1[nc] << nl;
      }

      y[i] = yi;
      i++;
    } else {
      for (i1 = nb; i1 < nc; i1++) {
        y[i] = u1[i1];
        i++;
      }
    }
  }

  while (i < n) {
    y[i] = 0U;
    i++;
  }
}

void uMultiWordMul(const uint32_T u1[], int32_T n1, const uint32_T u2[], int32_T
                   n2, uint32_T y[], int32_T n)
{
  int32_T i;
  int32_T j;
  int32_T k;
  int32_T ni;
  uint32_T u1i;
  uint32_T yk;
  uint32_T a1;
  uint32_T a0;
  uint32_T b1;
  uint32_T w10;
  uint32_T w01;
  uint32_T cb;
  for (k = 0; k < n; k++) {
    y[k] = 0U;
  }

  for (i = 0; i < n1; i++) {
    cb = 0U;
    u1i = u1[i];
    a1 = u1i >> 16U;
    a0 = u1i & 65535U;
    ni = n - i;
    ni = n2 <= ni ? n2 : ni;
    k = i;
    for (j = 0; j < ni; j++) {
      u1i = u2[j];
      b1 = u1i >> 16U;
      u1i &= 65535U;
      w10 = a1 * u1i;
      w01 = a0 * b1;
      yk = y[k] + cb;
      cb = (uint32_T)(yk < cb);
      u1i *= a0;
      yk += u1i;
      cb += (yk < u1i);
      u1i = w10 << 16U;
      yk += u1i;
      cb += (yk < u1i);
      u1i = w01 << 16U;
      yk += u1i;
      cb += (yk < u1i);
      y[k] = yk;
      cb += w10 >> 16U;
      cb += w01 >> 16U;
      cb += a1 * b1;
      k++;
    }

    if (k < n) {
      y[k] = cb;
    }
  }
}

void SeatMemoryModule_SeatHeatAct(int32_T NumIters, const uint8_T rtu_TgtTemp[2],
  const uint8_T rtu_HeatRateSet[2], const uint8_T rtu_SeatHeatLvl[2], const
  uint16_T rtu_NtcAd[2], uint8_T rtu_SteadyZoon, uint16_T rtu_EachStepTime,
  uint8_T rtu_NTC_OvTempThrshd, uint8_T rtu_DiffTempThrshd, uint16_T
  rtu_DiffTempConfTm, uint16_T rtu_FullPwHtOvTmThrshd, boolean_T rty_HeatCmd[2],
  uint8_T rty_HeatDuty[2], int16_T rty_NtcTmp[2], boolean_T rty_Heatfault[2],
  B_SeatHeatAct_SeatMemoryModul_T localB[2], DW_SeatHeatAct_SeatMemoryModu_T
  localDW[2])
{
  int32_T ForEach_itr;
  boolean_T rtb_LogicalOperator4_l4;
  int16_T rtb_uDLookupTable;
  uint8_T SeatHeatLvl_prev_d;
  uint16_T tmp;
  int32_T HeatCmd_tmp;
  for (ForEach_itr = 0; ForEach_itr < NumIters; ForEach_itr++) {
    rtb_uDLookupTable = look1_iu16lu16n16ts16D_RXQzuhbZ(rtu_NtcAd[ForEach_itr],
      gSMM_CfgTableNtcAd, gSMM_CfgTableNtcTmp, 36U);
    if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_l < 2047U) {
      localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_l++;
    }

    SeatHeatLvl_prev_d = localDW[ForEach_itr].CoreSubsys.SeatHeatLvl_start_g;
    localDW[ForEach_itr].CoreSubsys.SeatHeatLvl_start_g =
      rtu_SeatHeatLvl[ForEach_itr];
    if (localDW[ForEach_itr].CoreSubsys.is_active_c7_SeatMemoryModule == 0U) {
      localDW[ForEach_itr].CoreSubsys.is_active_c7_SeatMemoryModule = 1U;
      localDW[ForEach_itr].CoreSubsys.is_c7_SeatMemoryModule =
        SeatMemoryModule_IN_Default_k;
      localB[ForEach_itr].CoreSubsys.HeatFault_e = false;
    } else {
      switch (localDW[ForEach_itr].CoreSubsys.is_c7_SeatMemoryModule) {
       case SeatMemoryModule_IN_Confirm:
        if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_l >= 100) {
          localDW[ForEach_itr].CoreSubsys.is_c7_SeatMemoryModule =
            SeatMemoryModule_IN_Fault_a;
          localB[ForEach_itr].CoreSubsys.HeatFault_e = true;
        } else {
          if (rtb_uDLookupTable < rtu_NTC_OvTempThrshd) {
            localDW[ForEach_itr].CoreSubsys.is_c7_SeatMemoryModule =
              SeatMemoryModule_IN_Default_k;
            localB[ForEach_itr].CoreSubsys.HeatFault_e = false;
          }
        }
        break;

       case SeatMemoryModule_IN_Confirm1:
        if (rtb_uDLookupTable < rtu_NTC_OvTempThrshd - 20) {
          localDW[ForEach_itr].CoreSubsys.is_c7_SeatMemoryModule =
            SeatMemoryModule_IN_Default_k;
          localB[ForEach_itr].CoreSubsys.HeatFault_e = false;
        } else {
          if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_l >= 2000) {
            localDW[ForEach_itr].CoreSubsys.is_c7_SeatMemoryModule =
              SeatMemoryModule_IN_Fault_a;
            localB[ForEach_itr].CoreSubsys.HeatFault_e = true;
          }
        }
        break;

       case SeatMemoryModule_IN_Default_k:
        if (rtb_uDLookupTable > rtu_NTC_OvTempThrshd) {
          localDW[ForEach_itr].CoreSubsys.is_c7_SeatMemoryModule =
            SeatMemoryModule_IN_Confirm;
          localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_l = 0U;
        } else {
          if (rtb_uDLookupTable > rtu_NTC_OvTempThrshd - 20) {
            localDW[ForEach_itr].CoreSubsys.is_c7_SeatMemoryModule =
              SeatMemoryModule_IN_Confirm1;
            localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_l = 0U;
          }
        }
        break;

       default:
        if (SeatHeatLvl_prev_d != localDW[ForEach_itr].
            CoreSubsys.SeatHeatLvl_start_g) {
          localDW[ForEach_itr].CoreSubsys.is_c7_SeatMemoryModule =
            SeatMemoryModule_IN_Default_k;
          localB[ForEach_itr].CoreSubsys.HeatFault_e = false;
        }
        break;
      }
    }

    if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_n < 65535U) {
      localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_n++;
    }

    SeatHeatLvl_prev_d = localDW[ForEach_itr].CoreSubsys.SeatHeatLvl_start_b;
    localDW[ForEach_itr].CoreSubsys.SeatHeatLvl_start_b =
      rtu_SeatHeatLvl[ForEach_itr];
    if (localDW[ForEach_itr].CoreSubsys.is_active_c15_SeatMemoryModule == 0U) {
      localDW[ForEach_itr].CoreSubsys.is_active_c15_SeatMemoryModule = 1U;
      localDW[ForEach_itr].CoreSubsys.is_c15_SeatMemoryModule =
        SeatMemoryModule_IN_Default;
      localB[ForEach_itr].CoreSubsys.HeatFault_j = false;
    } else {
      switch (localDW[ForEach_itr].CoreSubsys.is_c15_SeatMemoryModule) {
       case SeatMemoryModule_IN_Confirm:
        if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_n >=
            rtu_DiffTempConfTm) {
          localDW[ForEach_itr].CoreSubsys.is_c15_SeatMemoryModule =
            SeatMemoryModule_IN_Fault;
          localB[ForEach_itr].CoreSubsys.HeatFault_j = true;
        } else {
          if ((rtb_uDLookupTable < rtu_TgtTemp[ForEach_itr] + rtu_DiffTempThrshd)
              && (rtb_uDLookupTable > rtu_TgtTemp[ForEach_itr] -
                  rtu_DiffTempThrshd)) {
            localDW[ForEach_itr].CoreSubsys.is_c15_SeatMemoryModule =
              SeatMemoryModule_IN_Default;
            localB[ForEach_itr].CoreSubsys.HeatFault_j = false;
          }
        }
        break;

       case SeatMemoryModule_IN_Default:
        if ((rtb_uDLookupTable > rtu_TgtTemp[ForEach_itr] + rtu_DiffTempThrshd) ||
            (rtb_uDLookupTable < rtu_TgtTemp[ForEach_itr] - rtu_DiffTempThrshd))
        {
          localDW[ForEach_itr].CoreSubsys.is_c15_SeatMemoryModule =
            SeatMemoryModule_IN_Confirm;
          localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_n = 0U;
        }
        break;

       default:
        if (SeatHeatLvl_prev_d != localDW[ForEach_itr].
            CoreSubsys.SeatHeatLvl_start_b) {
          localDW[ForEach_itr].CoreSubsys.is_c15_SeatMemoryModule =
            SeatMemoryModule_IN_Default;
          localB[ForEach_itr].CoreSubsys.HeatFault_j = false;
        }
        break;
      }
    }

    if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1 < 65535U) {
      localDW[ForEach_itr].CoreSubsys.temporalCounter_i1++;
    }

    SeatHeatLvl_prev_d = localDW[ForEach_itr].CoreSubsys.SeatHeatLvl_start;
    localDW[ForEach_itr].CoreSubsys.SeatHeatLvl_start =
      rtu_SeatHeatLvl[ForEach_itr];
    if (localDW[ForEach_itr].CoreSubsys.is_active_c6_SeatMemoryModule == 0U) {
      localDW[ForEach_itr].CoreSubsys.is_active_c6_SeatMemoryModule = 1U;
      localDW[ForEach_itr].CoreSubsys.is_c6_SeatMemoryModule =
        SeatMemoryModule_IN_Default;
      localB[ForEach_itr].CoreSubsys.HeatFault = false;
    } else {
      switch (localDW[ForEach_itr].CoreSubsys.is_c6_SeatMemoryModule) {
       case SeatMemoryModule_IN_Confirm:
        if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1 >=
            rtu_FullPwHtOvTmThrshd) {
          localDW[ForEach_itr].CoreSubsys.is_c6_SeatMemoryModule =
            SeatMemoryModule_IN_Fault;
          localB[ForEach_itr].CoreSubsys.HeatFault = true;
        } else {
          if (!localDW[ForEach_itr].CoreSubsys.UnitDelay_DSTATE) {
            localDW[ForEach_itr].CoreSubsys.is_c6_SeatMemoryModule =
              SeatMemoryModule_IN_Default;
            localB[ForEach_itr].CoreSubsys.HeatFault = false;
          }
        }
        break;

       case SeatMemoryModule_IN_Default:
        if (localDW[ForEach_itr].CoreSubsys.UnitDelay_DSTATE) {
          localDW[ForEach_itr].CoreSubsys.is_c6_SeatMemoryModule =
            SeatMemoryModule_IN_Confirm;
          localDW[ForEach_itr].CoreSubsys.temporalCounter_i1 = 0U;
        }
        break;

       default:
        if (SeatHeatLvl_prev_d != localDW[ForEach_itr].
            CoreSubsys.SeatHeatLvl_start) {
          localDW[ForEach_itr].CoreSubsys.is_c6_SeatMemoryModule =
            SeatMemoryModule_IN_Default;
          localB[ForEach_itr].CoreSubsys.HeatFault = false;
        }
        break;
      }
    }

    rtb_LogicalOperator4_l4 = (localB[ForEach_itr].CoreSubsys.HeatFault_e ||
      localB[ForEach_itr].CoreSubsys.HeatFault_j || localB[ForEach_itr].
      CoreSubsys.HeatFault);
    if ((rtu_SeatHeatLvl[ForEach_itr] >= 1) && (rtu_SeatHeatLvl[ForEach_itr] <=
         3)) {
      localDW[ForEach_itr].CoreSubsys.Subsystem_MODE = true;
      if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_fs < 65535U) {
        localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_fs++;
      }

      if (localDW[ForEach_itr].CoreSubsys.is_active_c14_SeatMemoryModule == 0U)
      {
        localDW[ForEach_itr].CoreSubsys.is_active_c14_SeatMemoryModule = 1U;
        localDW[ForEach_itr].CoreSubsys.is_c14_SeatMemoryModule =
          SeatMemoryModule_IN_Step1;
        localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_fs = 0U;
        localB[ForEach_itr].CoreSubsys.HeatCmd = false;
        localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
          (rtu_HeatRateSet[ForEach_itr] << 2) + rtu_TgtTemp[ForEach_itr]) ||
          localB[ForEach_itr].CoreSubsys.HeatCmd);
        localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
          ((rtu_HeatRateSet[ForEach_itr] << 2) + rtu_TgtTemp[ForEach_itr]) +
          rtu_SteadyZoon) && localB[ForEach_itr].CoreSubsys.HeatCmd);
      } else {
        switch (localDW[ForEach_itr].CoreSubsys.is_c14_SeatMemoryModule) {
         case SeatMemoryModule_IN_Step1:
          if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_fs >=
              rtu_EachStepTime) {
            localDW[ForEach_itr].CoreSubsys.is_c14_SeatMemoryModule =
              SeatMemoryModule_IN_Step2;
            localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_fs = 0U;
            localB[ForEach_itr].CoreSubsys.HeatCmd = false;
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable < 3 *
              rtu_HeatRateSet[ForEach_itr] + rtu_TgtTemp[ForEach_itr]) ||
              localB[ForEach_itr].CoreSubsys.HeatCmd);
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable < (3 *
              rtu_HeatRateSet[ForEach_itr] + rtu_TgtTemp[ForEach_itr]) +
              rtu_SteadyZoon) && localB[ForEach_itr].CoreSubsys.HeatCmd);
          } else {
            HeatCmd_tmp = (rtu_HeatRateSet[ForEach_itr] << 2) +
              rtu_TgtTemp[ForEach_itr];
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              HeatCmd_tmp) || localB[ForEach_itr].CoreSubsys.HeatCmd);
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              HeatCmd_tmp + rtu_SteadyZoon) && localB[ForEach_itr].
              CoreSubsys.HeatCmd);
          }
          break;

         case SeatMemoryModule_IN_Step2:
          if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_fs >=
              rtu_EachStepTime) {
            localDW[ForEach_itr].CoreSubsys.is_c14_SeatMemoryModule =
              SeatMemoryModule_IN_Step3;
            localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_fs = 0U;
            localB[ForEach_itr].CoreSubsys.HeatCmd = false;
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              (rtu_HeatRateSet[ForEach_itr] << 1) + rtu_TgtTemp[ForEach_itr]) ||
              localB[ForEach_itr].CoreSubsys.HeatCmd);
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              ((rtu_HeatRateSet[ForEach_itr] << 1) + rtu_TgtTemp[ForEach_itr]) +
              rtu_SteadyZoon) && localB[ForEach_itr].CoreSubsys.HeatCmd);
          } else {
            HeatCmd_tmp = 3 * rtu_HeatRateSet[ForEach_itr] +
              rtu_TgtTemp[ForEach_itr];
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              HeatCmd_tmp) || localB[ForEach_itr].CoreSubsys.HeatCmd);
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              HeatCmd_tmp + rtu_SteadyZoon) && localB[ForEach_itr].
              CoreSubsys.HeatCmd);
          }
          break;

         case SeatMemoryModule_IN_Step3:
          if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_fs >=
              rtu_EachStepTime) {
            localDW[ForEach_itr].CoreSubsys.is_c14_SeatMemoryModule =
              SeatMemoryModule_IN_Step4;
            localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_fs = 0U;
            localB[ForEach_itr].CoreSubsys.HeatCmd = false;
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              rtu_TgtTemp[ForEach_itr] + rtu_HeatRateSet[ForEach_itr]) ||
              localB[ForEach_itr].CoreSubsys.HeatCmd);
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              (rtu_TgtTemp[ForEach_itr] + rtu_HeatRateSet[ForEach_itr]) +
              rtu_SteadyZoon) && localB[ForEach_itr].CoreSubsys.HeatCmd);
          } else {
            HeatCmd_tmp = (rtu_HeatRateSet[ForEach_itr] << 1) +
              rtu_TgtTemp[ForEach_itr];
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              HeatCmd_tmp) || localB[ForEach_itr].CoreSubsys.HeatCmd);
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              HeatCmd_tmp + rtu_SteadyZoon) && localB[ForEach_itr].
              CoreSubsys.HeatCmd);
          }
          break;

         case SeatMemoryModule_IN_Step4:
          if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_fs >=
              rtu_EachStepTime) {
            localDW[ForEach_itr].CoreSubsys.is_c14_SeatMemoryModule =
              SeatMemoryModule_IN_Step5;
            localB[ForEach_itr].CoreSubsys.HeatCmd = false;
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              rtu_TgtTemp[ForEach_itr]) || localB[ForEach_itr].
              CoreSubsys.HeatCmd);
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              rtu_TgtTemp[ForEach_itr] + rtu_SteadyZoon) && localB[ForEach_itr].
              CoreSubsys.HeatCmd);
          } else {
            HeatCmd_tmp = rtu_TgtTemp[ForEach_itr] + rtu_HeatRateSet[ForEach_itr];
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              HeatCmd_tmp) || localB[ForEach_itr].CoreSubsys.HeatCmd);
            localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
              HeatCmd_tmp + rtu_SteadyZoon) && localB[ForEach_itr].
              CoreSubsys.HeatCmd);
          }
          break;

         default:
          localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
            rtu_TgtTemp[ForEach_itr]) || localB[ForEach_itr].CoreSubsys.HeatCmd);
          localB[ForEach_itr].CoreSubsys.HeatCmd = ((rtb_uDLookupTable <
            rtu_TgtTemp[ForEach_itr] + rtu_SteadyZoon) && localB[ForEach_itr].
            CoreSubsys.HeatCmd);
          break;
        }
      }

      localB[ForEach_itr].CoreSubsys.OutportBufferForHeatCmd =
        localB[ForEach_itr].CoreSubsys.HeatCmd;
    } else {
      if (localDW[ForEach_itr].CoreSubsys.Subsystem_MODE) {
        localB[ForEach_itr].CoreSubsys.OutportBufferForHeatCmd = false;
        localDW[ForEach_itr].CoreSubsys.Subsystem_MODE = false;
      }
    }

    localDW[ForEach_itr].CoreSubsys.UnitDelay_DSTATE = (localB[ForEach_itr].
      CoreSubsys.OutportBufferForHeatCmd && (!rtb_LogicalOperator4_l4));
    if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_f < 65535U) {
      localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_f++;
    }

    if (localDW[ForEach_itr].CoreSubsys.is_active_c8_SeatMemoryModule == 0U) {
      localDW[ForEach_itr].CoreSubsys.is_active_c8_SeatMemoryModule = 1U;
      localDW[ForEach_itr].CoreSubsys.is_c8_SeatMemoryModule =
        SeatMemoryModule_IN_Default;
      tmp = localDW[ForEach_itr].CoreSubsys.TempCnt;
      if (localDW[ForEach_itr].CoreSubsys.TempCnt > 255) {
        tmp = 255U;
      }

      localB[ForEach_itr].CoreSubsys.HeatCnt = (uint8_T)tmp;
    } else if (localDW[ForEach_itr].CoreSubsys.is_c8_SeatMemoryModule ==
               SeatMemoryModule_IN_Counter) {
      if (localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_f >= 255) {
        localDW[ForEach_itr].CoreSubsys.is_c8_SeatMemoryModule =
          SeatMemoryModule_IN_Default;
        tmp = localDW[ForEach_itr].CoreSubsys.TempCnt;
        if (localDW[ForEach_itr].CoreSubsys.TempCnt > 255) {
          tmp = 255U;
        }

        localB[ForEach_itr].CoreSubsys.HeatCnt = (uint8_T)tmp;
      } else {
        if (localDW[ForEach_itr].CoreSubsys.UnitDelay_DSTATE &&
            (localDW[ForEach_itr].CoreSubsys.TempCnt <= 255)) {
          HeatCmd_tmp = localDW[ForEach_itr].CoreSubsys.TempCnt + 1;
          if (HeatCmd_tmp > 65535) {
            HeatCmd_tmp = 65535;
          }

          localDW[ForEach_itr].CoreSubsys.TempCnt = (uint16_T)HeatCmd_tmp;
        }
      }
    } else {
      localDW[ForEach_itr].CoreSubsys.is_c8_SeatMemoryModule =
        SeatMemoryModule_IN_Counter;
      localDW[ForEach_itr].CoreSubsys.temporalCounter_i1_f = 0U;
      localDW[ForEach_itr].CoreSubsys.TempCnt = 0U;
      if (localDW[ForEach_itr].CoreSubsys.UnitDelay_DSTATE &&
          (localDW[ForEach_itr].CoreSubsys.TempCnt <= 255)) {
        HeatCmd_tmp = localDW[ForEach_itr].CoreSubsys.TempCnt + 1;
        if (HeatCmd_tmp > 65535) {
          HeatCmd_tmp = 65535;
        }

        localDW[ForEach_itr].CoreSubsys.TempCnt = (uint16_T)HeatCmd_tmp;
      }
    }

    rty_HeatDuty[ForEach_itr] = localB[ForEach_itr].CoreSubsys.HeatCnt;
    rty_HeatCmd[ForEach_itr] = localDW[ForEach_itr].CoreSubsys.UnitDelay_DSTATE;
    rty_Heatfault[ForEach_itr] = rtb_LogicalOperator4_l4;
    rty_NtcTmp[ForEach_itr] = rtb_uDLookupTable;
  }
}

void SeatHeatVentCtrl_10ms(void)
{
  int16_T rtb_ImpAsg_InsertedFor_NtcTmp_a[2];
  uint8_T rtb_ImpAsg_InsertedFor_HeatDuty[2];
  boolean_T rtb_ImpAsg_InsertedFor_HeatCmd_[2];
  uint8_T rtb_ImpAsg_InsertedFor_SeatVent[2];
  uint8_T rtb_Switch2_a;
  boolean_T rtb_LogicalOperator4_mx;
  boolean_T rtb_LogicalOperator7;
  uint8_T TmpSignalConversionAtHeatVentMe[2];
  uint8_T TmpSignalConversionAtHeatVent_b[2];
  uint8_T TmpSignalConversionAtHeatVen_bh[2];
  uint8_T TmpSignalConversionAtHeatVent_f[2];
  uint8_T TmpSignalConversionAtHeatVent_k[2];
  boolean_T TmpSignalConversionAtHeatVent_c[2];
  boolean_T TmpSignalConversionAtHeatVent_g[2];
  uint16_T TmpSignalConversionAtSeatHeatAc[2];
  TmpSignalConversionAtHeatVentMe[0] = gSMM_InU8Ms4DriverHeatVent;
  TmpSignalConversionAtHeatVentMe[1] = gSMM_InU8Ms4PassengerHeatVent;
  TmpSignalConversionAtHeatVent_b[0] = gSMM_InU8Seat1HeatFaultDtc;
  TmpSignalConversionAtHeatVent_b[1] = gSMM_InU8Seat2HeatFaultDtc;
  TmpSignalConversionAtHeatVen_bh[0] = gSMM_InU8Seat1VentFaultDtc;
  TmpSignalConversionAtHeatVen_bh[1] = gSMM_InU8Seat2VentFaultDtc;
  TmpSignalConversionAtHeatVent_f[0] = gSMM_InU8TboxDriverHeat;
  TmpSignalConversionAtHeatVent_f[1] = gSMM_InU8TboxPassengerHeat;
  TmpSignalConversionAtHeatVent_k[0] = gSMM_InU8TboxDriverVent;
  TmpSignalConversionAtHeatVent_k[1] = gSMM_InU8TboxPassengerVent;
  TmpSignalConversionAtHeatVent_c[0] = gSMM_InBlCcpDriverHeat;
  TmpSignalConversionAtHeatVent_c[1] = gSMM_InBlCcpPassengerHeat;
  TmpSignalConversionAtHeatVent_g[0] = gSMM_InBlCcpDriverVent;
  TmpSignalConversionAtHeatVent_g[1] = gSMM_InBlCcpPassengerVent;
  if ((TmpSignalConversionAtHeatVent_b[0] != 0) || (gSMM_inU8IGNSts < 2) ||
      (gSMM_InU8EngineRunning == 0) || SeatMemoryModule_DW.CoreSubsys[0].
      UnitDelay_DSTATE_n) {
    SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE = 7U;
  } else {
    if ((TmpSignalConversionAtHeatVentMe[0] != SeatMemoryModule_DW.CoreSubsys[0]
         .DelayInput1_DSTATE) && (((TmpSignalConversionAtHeatVentMe[0] != 0) &&
          (TmpSignalConversionAtHeatVentMe[0] <= 3)) ||
         (TmpSignalConversionAtHeatVentMe[0] == 7))) {
      rtb_Switch2_a = TmpSignalConversionAtHeatVentMe[0];
    } else if ((TmpSignalConversionAtHeatVent_f[0] !=
                SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_d) &&
               (TmpSignalConversionAtHeatVent_f[0] != 0)) {
      rtb_Switch2_a = TmpSignalConversionAtHeatVent_f[0];
    } else {
      rtb_LogicalOperator4_mx = ((TmpSignalConversionAtHeatVent_c[0] !=
        SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_g) &&
        TmpSignalConversionAtHeatVent_c[0]);
      rtb_LogicalOperator7 = ((SeatMemoryModule_DW.CoreSubsys[0].
        UnitDelay_DSTATE == 7) || (SeatMemoryModule_DW.CoreSubsys[0].
        UnitDelay_DSTATE == 0));
      if (rtb_LogicalOperator4_mx && rtb_LogicalOperator7) {
        rtb_Switch2_a = 3U;
      } else if ((!rtb_LogicalOperator7) && rtb_LogicalOperator4_mx) {
        rtb_Switch2_a = 7U;
      } else {
        rtb_Switch2_a = SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE;
      }
    }

    SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE = rtb_Switch2_a;
  }

  if (SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE > 3) {
    rtb_Switch2_a = 3U;
  } else if (SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE < 1) {
    rtb_Switch2_a = 1U;
  } else {
    rtb_Switch2_a = SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE;
  }

  switch (rtb_Switch2_a) {
   case 1:
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtRate_at_i[0] = 5U;
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtTemp_at_i[0] =
      gSMM_CfgU8HeatLowTgtTemp;
    break;

   case 2:
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtRate_at_i[0] = 7U;
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtTemp_at_i[0] =
      gSMM_CfgU8HeatMidTgtTemp;
    break;

   default:
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtRate_at_i[0] = 10U;
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtTemp_at_i[0] =
      gSMM_CfgU8HeatHighTgtTemp;
    break;
  }

  if ((TmpSignalConversionAtHeatVen_bh[0] != 0) || (gSMM_inU8IGNSts < 2) ||
      (gSMM_InU8EngineRunning == 0) || ((SeatMemoryModule_DW.CoreSubsys[0].
        UnitDelay_DSTATE != SeatMemoryModule_DW.CoreSubsys[0].
        DelayInput1_DSTATE_dv) && (SeatMemoryModule_DW.CoreSubsys[0].
        UnitDelay_DSTATE >= 1) && (SeatMemoryModule_DW.CoreSubsys[0].
        UnitDelay_DSTATE <= 3))) {
    SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j = 7U;
  } else {
    rtb_LogicalOperator4_mx = (TmpSignalConversionAtHeatVentMe[0] !=
      SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_c);
    if ((TmpSignalConversionAtHeatVentMe[0] == 7) && rtb_LogicalOperator4_mx) {
      rtb_Switch2_a = 7U;
    } else if (rtb_LogicalOperator4_mx && (TmpSignalConversionAtHeatVentMe[0] >=
                4)) {
      rtb_Switch2_a = (uint8_T)(TmpSignalConversionAtHeatVentMe[0] - 3);
    } else if ((TmpSignalConversionAtHeatVent_k[0] !=
                SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_h) &&
               (TmpSignalConversionAtHeatVent_k[0] != 0)) {
      rtb_Switch2_a = TmpSignalConversionAtHeatVent_k[0];
    } else {
      rtb_LogicalOperator4_mx = ((TmpSignalConversionAtHeatVent_g[0] !=
        SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_i) &&
        TmpSignalConversionAtHeatVent_g[0]);
      rtb_LogicalOperator7 = ((SeatMemoryModule_DW.CoreSubsys[0].
        UnitDelay_DSTATE_j == 7) || (SeatMemoryModule_DW.CoreSubsys[0].
        UnitDelay_DSTATE_j == 0));
      if (rtb_LogicalOperator4_mx && rtb_LogicalOperator7) {
        rtb_Switch2_a = 3U;
      } else if ((!rtb_LogicalOperator7) && rtb_LogicalOperator4_mx) {
        rtb_Switch2_a = 7U;
      } else {
        rtb_Switch2_a = SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j;
      }
    }

    SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j = rtb_Switch2_a;
  }

  if (SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j == 7) {
    rtb_Switch2_a = 1U;
  } else if (SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j > 4) {
    rtb_Switch2_a = 4U;
  } else if (SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j < 1) {
    rtb_Switch2_a = 1U;
  } else {
    rtb_Switch2_a = SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j;
  }

  switch (rtb_Switch2_a) {
   case 1:
    rtb_ImpAsg_InsertedFor_SeatVent[0] = 0U;
    break;

   case 2:
    rtb_ImpAsg_InsertedFor_SeatVent[0] = gSMM_CfgU8VentLowTgtDuty;
    break;

   case 3:
    rtb_ImpAsg_InsertedFor_SeatVent[0] = gSMM_CfgU8VentMidTgtDuty;
    break;

   default:
    rtb_ImpAsg_InsertedFor_SeatVent[0] = gSMM_CfgU8VentHighTgtDuty;
    break;
  }

  if ((SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE == 7) &&
      (SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j == 7)) {
    SeatMemoryModule_B.ImpAsg_InsertedFor_SeatHeatVent[0] = 7U;
  } else if ((SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE >= 1) &&
             (SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE <= 3)) {
    SeatMemoryModule_B.ImpAsg_InsertedFor_SeatHeatVent[0] =
      SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE;
  } else if ((SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j >= 1) &&
             (SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j <= 3)) {
    SeatMemoryModule_B.ImpAsg_InsertedFor_SeatHeatVent[0] = (uint8_T)
      (SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j + 3U);
  } else {
    SeatMemoryModule_B.ImpAsg_InsertedFor_SeatHeatVent[0] = 0U;
  }

  SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_dv =
    SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_l;
  SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_n =
    ((SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j !=
      SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_dv) &&
     (SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j >= 1) &&
     (SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j <= 3));
  SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE =
    TmpSignalConversionAtHeatVentMe[0];
  SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_d =
    TmpSignalConversionAtHeatVent_f[0];
  SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_g =
    TmpSignalConversionAtHeatVent_c[0];
  SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_dv =
    SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE;
  SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_c =
    TmpSignalConversionAtHeatVentMe[0];
  SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_h =
    TmpSignalConversionAtHeatVent_k[0];
  SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_i =
    TmpSignalConversionAtHeatVent_g[0];
  SeatMemoryModule_DW.CoreSubsys[0].DelayInput1_DSTATE_l =
    SeatMemoryModule_DW.CoreSubsys[0].UnitDelay_DSTATE_j;
  if ((TmpSignalConversionAtHeatVent_b[1] != 0) || (gSMM_inU8IGNSts < 2) ||
      (gSMM_InU8EngineRunning == 0) || SeatMemoryModule_DW.CoreSubsys[1].
      UnitDelay_DSTATE_n) {
    SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE = 7U;
  } else {
    if ((TmpSignalConversionAtHeatVentMe[1] != SeatMemoryModule_DW.CoreSubsys[1]
         .DelayInput1_DSTATE) && (((TmpSignalConversionAtHeatVentMe[1] != 0) &&
          (TmpSignalConversionAtHeatVentMe[1] <= 3)) ||
         (TmpSignalConversionAtHeatVentMe[1] == 7))) {
      rtb_Switch2_a = TmpSignalConversionAtHeatVentMe[1];
    } else if ((TmpSignalConversionAtHeatVent_f[1] !=
                SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_d) &&
               (TmpSignalConversionAtHeatVent_f[1] != 0)) {
      rtb_Switch2_a = TmpSignalConversionAtHeatVent_f[1];
    } else {
      rtb_LogicalOperator4_mx = ((TmpSignalConversionAtHeatVent_c[1] !=
        SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_g) &&
        TmpSignalConversionAtHeatVent_c[1]);
      rtb_LogicalOperator7 = ((SeatMemoryModule_DW.CoreSubsys[1].
        UnitDelay_DSTATE == 7) || (SeatMemoryModule_DW.CoreSubsys[1].
        UnitDelay_DSTATE == 0));
      if (rtb_LogicalOperator4_mx && rtb_LogicalOperator7) {
        rtb_Switch2_a = 3U;
      } else if ((!rtb_LogicalOperator7) && rtb_LogicalOperator4_mx) {
        rtb_Switch2_a = 7U;
      } else {
        rtb_Switch2_a = SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE;
      }
    }

    SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE = rtb_Switch2_a;
  }

  if (SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE > 3) {
    rtb_Switch2_a = 3U;
  } else if (SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE < 1) {
    rtb_Switch2_a = 1U;
  } else {
    rtb_Switch2_a = SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE;
  }

  switch (rtb_Switch2_a) {
   case 1:
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtRate_at_i[1] = 5U;
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtTemp_at_i[1] =
      gSMM_CfgU8HeatLowTgtTemp;
    break;

   case 2:
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtRate_at_i[1] = 7U;
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtTemp_at_i[1] =
      gSMM_CfgU8HeatMidTgtTemp;
    break;

   default:
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtRate_at_i[1] = 10U;
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtTemp_at_i[1] =
      gSMM_CfgU8HeatHighTgtTemp;
    break;
  }

  if ((TmpSignalConversionAtHeatVen_bh[1] != 0) || (gSMM_inU8IGNSts < 2) ||
      (gSMM_InU8EngineRunning == 0) || ((SeatMemoryModule_DW.CoreSubsys[1].
        UnitDelay_DSTATE != SeatMemoryModule_DW.CoreSubsys[1].
        DelayInput1_DSTATE_dv) && (SeatMemoryModule_DW.CoreSubsys[1].
        UnitDelay_DSTATE >= 1) && (SeatMemoryModule_DW.CoreSubsys[1].
        UnitDelay_DSTATE <= 3))) {
    SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j = 7U;
  } else {
    rtb_LogicalOperator4_mx = (TmpSignalConversionAtHeatVentMe[1] !=
      SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_c);
    if ((TmpSignalConversionAtHeatVentMe[1] == 7) && rtb_LogicalOperator4_mx) {
      rtb_Switch2_a = 7U;
    } else if (rtb_LogicalOperator4_mx && (TmpSignalConversionAtHeatVentMe[1] >=
                4)) {
      rtb_Switch2_a = (uint8_T)(TmpSignalConversionAtHeatVentMe[1] - 3);
    } else if ((TmpSignalConversionAtHeatVent_k[1] !=
                SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_h) &&
               (TmpSignalConversionAtHeatVent_k[1] != 0)) {
      rtb_Switch2_a = TmpSignalConversionAtHeatVent_k[1];
    } else {
      rtb_LogicalOperator4_mx = ((TmpSignalConversionAtHeatVent_g[1] !=
        SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_i) &&
        TmpSignalConversionAtHeatVent_g[1]);
      rtb_LogicalOperator7 = ((SeatMemoryModule_DW.CoreSubsys[1].
        UnitDelay_DSTATE_j == 7) || (SeatMemoryModule_DW.CoreSubsys[1].
        UnitDelay_DSTATE_j == 0));
      if (rtb_LogicalOperator4_mx && rtb_LogicalOperator7) {
        rtb_Switch2_a = 3U;
      } else if ((!rtb_LogicalOperator7) && rtb_LogicalOperator4_mx) {
        rtb_Switch2_a = 7U;
      } else {
        rtb_Switch2_a = SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j;
      }
    }

    SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j = rtb_Switch2_a;
  }

  if (SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j == 7) {
    rtb_Switch2_a = 1U;
  } else if (SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j > 4) {
    rtb_Switch2_a = 4U;
  } else if (SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j < 1) {
    rtb_Switch2_a = 1U;
  } else {
    rtb_Switch2_a = SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j;
  }

  switch (rtb_Switch2_a) {
   case 1:
    rtb_ImpAsg_InsertedFor_SeatVent[1] = 0U;
    break;

   case 2:
    rtb_ImpAsg_InsertedFor_SeatVent[1] = gSMM_CfgU8VentLowTgtDuty;
    break;

   case 3:
    rtb_ImpAsg_InsertedFor_SeatVent[1] = gSMM_CfgU8VentMidTgtDuty;
    break;

   default:
    rtb_ImpAsg_InsertedFor_SeatVent[1] = gSMM_CfgU8VentHighTgtDuty;
    break;
  }

  if ((SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE == 7) &&
      (SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j == 7)) {
    SeatMemoryModule_B.ImpAsg_InsertedFor_SeatHeatVent[1] = 7U;
  } else if ((SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE >= 1) &&
             (SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE <= 3)) {
    SeatMemoryModule_B.ImpAsg_InsertedFor_SeatHeatVent[1] =
      SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE;
  } else if ((SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j >= 1) &&
             (SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j <= 3)) {
    SeatMemoryModule_B.ImpAsg_InsertedFor_SeatHeatVent[1] = (uint8_T)
      (SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j + 3U);
  } else {
    SeatMemoryModule_B.ImpAsg_InsertedFor_SeatHeatVent[1] = 0U;
  }

  SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_dv =
    SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_l;
  SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_n =
    ((SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j !=
      SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_dv) &&
     (SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j >= 1) &&
     (SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j <= 3));
  SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE =
    TmpSignalConversionAtHeatVentMe[1];
  SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_d =
    TmpSignalConversionAtHeatVent_f[1];
  SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_g =
    TmpSignalConversionAtHeatVent_c[1];
  SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_dv =
    SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE;
  SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_c =
    TmpSignalConversionAtHeatVentMe[1];
  SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_h =
    TmpSignalConversionAtHeatVent_k[1];
  SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_i =
    TmpSignalConversionAtHeatVent_g[1];
  SeatMemoryModule_DW.CoreSubsys[1].DelayInput1_DSTATE_l =
    SeatMemoryModule_DW.CoreSubsys[1].UnitDelay_DSTATE_j;
  TmpSignalConversionAtSeatHeatAc[0] = gSMM_InU16Seat1NtcAd;
  TmpSignalConversionAtSeatHeatAc[1] = gSMM_InU16Seat2NtcAd;
  SeatMemoryModule_SeatHeatAct(2,
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtTemp_at_i,
    SeatMemoryModule_B.ImpAsg_InsertedFor_TgtRate_at_i,
    SeatMemoryModule_B.ImpAsg_InsertedFor_SeatHeatVent,
    TmpSignalConversionAtSeatHeatAc, 0, 1, 90, 10, 60000, 30000,
    rtb_ImpAsg_InsertedFor_HeatCmd_, rtb_ImpAsg_InsertedFor_HeatDuty,
    rtb_ImpAsg_InsertedFor_NtcTmp_a, TmpSignalConversionAtHeatVent_c,
    SeatMemoryModule_B.SeatHeatAct, SeatMemoryModule_DW.SeatHeatAct);
  gSMM_OutBlSeat1HeatCmd = rtb_ImpAsg_InsertedFor_HeatCmd_[0];
  gSMM_OutBlSeat2HeatCmd = rtb_ImpAsg_InsertedFor_HeatCmd_[1];
  gSMM_OutU8Seat1HeatDuty = rtb_ImpAsg_InsertedFor_HeatDuty[0];
  gSMM_OutU8Seat2HeatDuty = rtb_ImpAsg_InsertedFor_HeatDuty[1];
  gSMM_OutS16Seat1NtcTmp = rtb_ImpAsg_InsertedFor_NtcTmp_a[0];
  gSMM_OutS16Seat2NtcTmp = rtb_ImpAsg_InsertedFor_NtcTmp_a[1];
  gSMM_OutU8Seat1HeatVentSts =
    SeatMemoryModule_B.ImpAsg_InsertedFor_SeatHeatVent[0];
  gSMM_OutU8Seat2HeatVentSts =
    SeatMemoryModule_B.ImpAsg_InsertedFor_SeatHeatVent[1];
  gSMM_OutU8Seat1VentDuty = (uint8_T)((rtb_ImpAsg_InsertedFor_SeatVent[0] *
    10445U) >> 12);
  gSMM_OutU8Seat2VentDuty = (uint8_T)((rtb_ImpAsg_InsertedFor_SeatVent[1] *
    10445U) >> 12);
}

void SeatMotionCtrl_10ms(void)
{
  uint16_T rtb_ImpAsg_InsertedFor_AccountH[21];
  boolean_T rtb_LogicalOperator_nk;
  boolean_T rtb_Compare_pu[7];
  boolean_T rtb_TmpSignalConversionAtSubs_g[7];
  uint8_T rtb_ImpAsg_InsertedFor_AutoPosS[7];
  boolean_T rtb_LogicalOperator2_a;
  uint16_T rtb_DataTypeConversion[3];
  uint16_T rtb_TmpSignalConversionAtSubs_f[3];
  boolean_T rtb_TmpSignalConversionAtSubs_h[3];
  uint8_T rtb_Switch4_ii[7];
  boolean_T rtb_ImpAsg_InsertedFor_Accoun_e[3];
  uint16_T rtb_TgtHall[7];
  uint8_T rtb_Switch2;
  uint8_T rtb_Switch1_e;
  uint8_T rtb_Switch7_g;
  uint8_T rtb_Switch11;
  uint8_T rtb_Switch9_n;
  uint8_T rtb_Switch13;
  uint8_T rtb_ImpAsg_InsertedFor_CtrlRe_c[7];
  boolean_T rtb_Delete;
  uint16_T TmpSignalConversionAtAccount123[21];
  uint8_T TmpSignalConversionAtAccount1_n[3];
  int32_T ForEach_itr_n0;
  uint8_T AccountApply_prev;
  uint8_T CurrAccount_prev;
  boolean_T CurrAccount_prev_p;
  int32_T i;
  int32_T ForEach_itr_n0_0;
  uint16_T tmp[3];
  uint64m_T tmp_0;
  uint64m_T tmp_1;
  uint32_T tmp_2;
  uint32_T tmp_3;
  uint64m_T tmp_4;
  uint64m_T tmp_5;
  boolean_T guard1 = false;
  boolean_T guard2 = false;
  for (i = 0; i < 7; i++) {
    TmpSignalConversionAtAccount123[i] = gSMM_inU16Account1HallFromEE[i];
    TmpSignalConversionAtAccount123[i + 7] = gSMM_inU16Account2HallFromEE[i];
    TmpSignalConversionAtAccount123[i + 14] = gSMM_inU16Account3HallFromEE[i];
  }

  TmpSignalConversionAtAccount1_n[0] = gSMM_inU8MemAccount1;
  TmpSignalConversionAtAccount1_n[1] = gSMM_inU8MemAccount2;
  TmpSignalConversionAtAccount1_n[2] = gSMM_inU8MemAccount3;
  for (ForEach_itr_n0 = 0; ForEach_itr_n0 < 3; ForEach_itr_n0++) {
    if (SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0].icLoad != 0) {
      ForEach_itr_n0_0 = ForEach_itr_n0 * 7;
      for (i = 0; i < 7; i++) {
        SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0]
          .ResettableDelay_DSTATE[i] = TmpSignalConversionAtAccount123[i +
          ForEach_itr_n0_0];
      }
    }

    for (i = 0; i < 7; i++) {
      rtb_ImpAsg_InsertedFor_AccountH[i + ForEach_itr_n0 * 7] =
        SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0]
        .ResettableDelay_DSTATE[i];
    }

    rtb_LogicalOperator_nk = (TmpSignalConversionAtAccount1_n[ForEach_itr_n0] !=
      SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0].DelayInput1_DSTATE);
    rtb_Delete = (rtb_LogicalOperator_nk &&
                  (TmpSignalConversionAtAccount1_n[ForEach_itr_n0] == 2));
    rtb_LogicalOperator_nk = ((TmpSignalConversionAtAccount1_n[ForEach_itr_n0] ==
      1) && rtb_LogicalOperator_nk);
    if (rtb_LogicalOperator_nk) {
      SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0].ResettableDelay_DSTATE[0]
        = gSMM_inU16DrvSeatCusQhHall;
      SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0].ResettableDelay_DSTATE[1]
        = gSMM_inU16DrvSeatCusSzHall;
      SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0].ResettableDelay_DSTATE[2]
        = gSMM_inU16DrvSeatBckQhHall;
      SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0].ResettableDelay_DSTATE[3]
        = gSMM_inU16DrvMirrorQj1Hall;
      SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0].ResettableDelay_DSTATE[4]
        = gSMM_inU16DrvMirrorQj2Hall;
      SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0].ResettableDelay_DSTATE[5]
        = gSMM_inU16PssMirrorQj1Hall;
      SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0].ResettableDelay_DSTATE[6]
        = gSMM_inU16PssMirrorQj2Hall;
    } else {
      if (rtb_Delete) {
        for (i = 0; i < 7; i++) {
          SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0].
            ResettableDelay_DSTATE[i] = 0U;
        }
      }
    }

    SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0].icLoad = 0U;
    SeatMemoryModule_DW.CoreSubsys_p[ForEach_itr_n0].DelayInput1_DSTATE =
      TmpSignalConversionAtAccount1_n[ForEach_itr_n0];
    rtb_ImpAsg_InsertedFor_Accoun_e[ForEach_itr_n0] = (rtb_LogicalOperator_nk ||
      rtb_Delete);
  }

  for (i = 0; i < 7; i++) {
    gSMM_OutU16Account1HallToEE[i] = rtb_ImpAsg_InsertedFor_AccountH[i];
    gSMM_OutU16Account2HallToEE[i] = rtb_ImpAsg_InsertedFor_AccountH[i + 7];
    gSMM_OutU16Account3HallToEE[i] = rtb_ImpAsg_InsertedFor_AccountH[i + 14];
  }

  if (SeatMemoryModule_DW.temporalCounter_i1 < 255U) {
    SeatMemoryModule_DW.temporalCounter_i1++;
  }

  rtb_LogicalOperator_nk = SeatMemoryModule_DW.SeatMemSw_start;
  SeatMemoryModule_DW.SeatMemSw_start = gSMM_inBlSeatMemEnSw;
  if (SeatMemoryModule_DW.is_active_c13_SeatMemoryModule == 0U) {
    SeatMemoryModule_DW.is_active_c13_SeatMemoryModule = 1U;
    SeatMemoryModule_DW.is_c13_SeatMemoryModule = SeatMemoryModule_IN_Default_p;
    gSMM_OutBlSeatMemSwReq = 0U;
  } else {
    switch (SeatMemoryModule_DW.is_c13_SeatMemoryModule) {
     case SeatMemoryModule_IN_Active:
      gSMM_OutBlSeatMemSwReq = 1U;
      if (SeatMemoryModule_DW.temporalCounter_i1 >= 3) {
        SeatMemoryModule_DW.is_c13_SeatMemoryModule =
          SeatMemoryModule_IN_Default_p;
        gSMM_OutBlSeatMemSwReq = 0U;
      }
      break;

     case SeatMemoryModule_IN_Cofirm:
      if (SeatMemoryModule_DW.temporalCounter_i1 >= 200) {
        SeatMemoryModule_DW.is_c13_SeatMemoryModule =
          SeatMemoryModule_IN_Default_p;
        gSMM_OutBlSeatMemSwReq = 0U;
      } else {
        if (!gSMM_inBlSeatMemEnSw) {
          SeatMemoryModule_DW.is_c13_SeatMemoryModule =
            SeatMemoryModule_IN_Active;
          SeatMemoryModule_DW.temporalCounter_i1 = 0U;
          gSMM_OutBlSeatMemSwReq = 1U;
        }
      }
      break;

     default:
      gSMM_OutBlSeatMemSwReq = 0U;
      if ((rtb_LogicalOperator_nk != SeatMemoryModule_DW.SeatMemSw_start) &&
          SeatMemoryModule_DW.SeatMemSw_start) {
        SeatMemoryModule_DW.is_c13_SeatMemoryModule = SeatMemoryModule_IN_Cofirm;
        SeatMemoryModule_DW.temporalCounter_i1 = 0U;
      }
      break;
    }
  }

  if (SeatMemoryModule_DW.temporalCounter_i1_o < 15U) {
    SeatMemoryModule_DW.temporalCounter_i1_o++;
  }

  AccountApply_prev = SeatMemoryModule_DW.AccountApply_start;
  SeatMemoryModule_DW.AccountApply_start = gSMM_inU8AccountApply;
  if (SeatMemoryModule_DW.is_active_c9_SeatMemoryModule == 0U) {
    SeatMemoryModule_DW.is_active_c9_SeatMemoryModule = 1U;
    SeatMemoryModule_DW.is_c9_SeatMemoryModule = SeatMemoryModule_IN_Default_i;
    SeatMemoryModule_B.CurrAccount = 0U;
  } else {
    switch (SeatMemoryModule_DW.is_c9_SeatMemoryModule) {
     case SeatMemory_IN_AccountChgConfirm:
      if (SeatMemoryModule_DW.temporalCounter_i1_o >= 10) {
        SeatMemoryModule_DW.is_c9_SeatMemoryModule =
          SeatMemoryModule_IN_Default_i;
        SeatMemoryModule_B.CurrAccount = 0U;
      } else {
        tmp[0] = gSMM_OutU16Account1HallToEE[0];
        tmp[1] = gSMM_OutU16Account2HallToEE[0];
        tmp[2] = gSMM_OutU16Account3HallToEE[0];
        if (tmp[gSMM_inU8AccountApply - 1] > 0) {
          SeatMemoryModule_DW.is_c9_SeatMemoryModule =
            SeatMemoryModule_IN_NotDefault;
          SeatMemoryModule_B.CurrAccount = gSMM_inU8AccountApply;
        }
      }
      break;

     case SeatMemoryModule_IN_Default_i:
      if ((AccountApply_prev != SeatMemoryModule_DW.AccountApply_start) &&
          (gSMM_inU8AccountApply > 0)) {
        SeatMemoryModule_DW.is_c9_SeatMemoryModule =
          SeatMemory_IN_AccountChgConfirm;
        SeatMemoryModule_DW.temporalCounter_i1_o = 0U;
      }
      break;

     default:
      if ((AccountApply_prev != SeatMemoryModule_DW.AccountApply_start) &&
          (gSMM_inU8AccountApply > 0)) {
        SeatMemoryModule_DW.is_c9_SeatMemoryModule =
          SeatMemory_IN_AccountChgConfirm;
        SeatMemoryModule_DW.temporalCounter_i1_o = 0U;
      } else {
        if (SeatMemoryModule_DW.UnitDelay1_DSTATE == 2) {
          SeatMemoryModule_DW.is_c9_SeatMemoryModule =
            SeatMemoryModule_IN_Default_i;
          SeatMemoryModule_B.CurrAccount = 0U;
        }
      }
      break;
    }
  }

  for (i = 0; i < 7; i++) {
    if (SeatMemoryModule_DW.icLoad != 0) {
      SeatMemoryModule_DW.ResettableDelay_DSTATE[i] =
        gSMM_inU16Account0HallFromEE[i];
    }

    gSMM_OutU16Account0HallToEE[i] =
      SeatMemoryModule_DW.ResettableDelay_DSTATE[i];
  }

  if (SeatMemoryModule_B.CurrAccount == 3) {
    for (i = 0; i < 7; i++) {
      rtb_TgtHall[i] = gSMM_OutU16Account3HallToEE[i];
    }
  } else if (SeatMemoryModule_B.CurrAccount == 2) {
    for (i = 0; i < 7; i++) {
      rtb_TgtHall[i] = gSMM_OutU16Account2HallToEE[i];
    }
  } else {
    rtb_LogicalOperator_nk = (SeatMemoryModule_B.CurrAccount == 1);
    for (i = 0; i < 7; i++) {
      if (rtb_LogicalOperator_nk) {
        rtb_TgtHall[i] = gSMM_OutU16Account1HallToEE[i];
      } else {
        rtb_TgtHall[i] = gSMM_OutU16Account0HallToEE[i];
      }
    }
  }

  gSMM_OutU8AccountApplySts = SeatMemoryModule_DW.UnitDelay_DSTATE;
  if (SeatMemoryModule_DW.temporalCounter_i1_a < 3U) {
    SeatMemoryModule_DW.temporalCounter_i1_a++;
  }

  rtb_LogicalOperator_nk = SeatMemoryModule_DW.ReverseGearSts_start;
  SeatMemoryModule_DW.ReverseGearSts_start = gSMM_inBlReverseGearSts;
  AccountApply_prev = SeatMemoryModule_DW.IGN_start;
  SeatMemoryModule_DW.IGN_start = gSMM_inU8IGNSts;
  if (SeatMemoryModule_DW.is_active_c10_SeatMemoryModule == 0U) {
    SeatMemoryModule_DW.is_active_c10_SeatMemoryModule = 1U;
    SeatMemoryModule_DW.is_c10_SeatMemoryModule = SeatMemoryModule_IN_Init;
    gSMM_OutU16Account0HallToEESw = false;
  } else if (SeatMemoryModule_DW.is_c10_SeatMemoryModule ==
             SeatMemoryModule_IN_Init) {
    if (((gSMM_OutU8AccountApplySts == 0) && gSMM_inBlReverseGearValid &&
         (rtb_LogicalOperator_nk != SeatMemoryModule_DW.ReverseGearSts_start)) ||
        ((gSMM_OutU8AccountApplySts != 0) && ((AccountApply_prev !=
           SeatMemoryModule_DW.IGN_start) && (SeatMemoryModule_DW.IGN_start == 0))))
    {
      SeatMemoryModule_DW.is_c10_SeatMemoryModule = SeatMemoryModule_IN_Update;
      SeatMemoryModule_DW.temporalCounter_i1_a = 0U;
      gSMM_OutU16Account0HallToEESw = true;
    }
  } else {
    if (SeatMemoryModule_DW.temporalCounter_i1_a >= 3) {
      SeatMemoryModule_DW.is_c10_SeatMemoryModule = SeatMemoryModule_IN_Init;
      gSMM_OutU16Account0HallToEESw = false;
    }
  }

  if (gSMM_inBlFrdSw) {
    AccountApply_prev = 1U;
  } else if (gSMM_inBlRrwSw) {
    AccountApply_prev = 2U;
  } else {
    AccountApply_prev = 0U;
  }

  if (gSMM_inBlFuSw) {
    rtb_Switch2 = 1U;
  } else if (gSMM_inBlFdSw) {
    rtb_Switch2 = 2U;
  } else {
    rtb_Switch2 = 0U;
  }

  if (gSMM_inBlBfSw) {
    rtb_Switch1_e = 1U;
  } else if (gSMM_inBlBrSw) {
    rtb_Switch1_e = 2U;
  } else {
    rtb_Switch1_e = 0U;
  }

  if (gSMM_inBlMirrBfSw) {
    rtb_Switch7_g = 1U;
  } else if (gSMM_inBlMirrBrSw) {
    rtb_Switch7_g = 2U;
  } else {
    rtb_Switch7_g = 0U;
  }

  rtb_LogicalOperator_nk = (gSMM_inU8MirrSlctSw == 1);
  if (gSMM_inBlMirrLfSw) {
    rtb_Switch9_n = 1U;
  } else if (gSMM_inBlMirrRtSw) {
    rtb_Switch9_n = 2U;
  } else {
    rtb_Switch9_n = 0U;
  }

  if (rtb_LogicalOperator_nk) {
    rtb_Switch11 = rtb_Switch7_g;
    rtb_Switch13 = rtb_Switch9_n;
  } else {
    rtb_Switch11 = 0U;
    rtb_Switch13 = 0U;
  }

  if (gSMM_inU8MirrSlctSw != 2) {
    rtb_Switch7_g = 0U;
    rtb_Switch9_n = 0U;
  }

  rtb_Compare_pu[0] = (AccountApply_prev != 0);
  rtb_Compare_pu[1] = (rtb_Switch2 != 0);
  rtb_Compare_pu[2] = (rtb_Switch1_e != 0);
  rtb_Compare_pu[3] = (rtb_Switch11 != 0);
  rtb_Compare_pu[4] = (rtb_Switch13 != 0);
  rtb_Compare_pu[5] = (rtb_Switch7_g != 0);
  rtb_Compare_pu[6] = (rtb_Switch9_n != 0);
  rtb_LogicalOperator_nk = rtb_Compare_pu[0];
  for (i = 0; i < 6; i++) {
    rtb_LogicalOperator_nk = (rtb_LogicalOperator_nk || rtb_Compare_pu[i + 1]);
  }

  rtb_Delete = (rtb_LogicalOperator_nk || (gSMM_inU8CrashIntensity == 1) ||
                ((gSMM_inU16VehicleSpeed > 200) && gSMM_inU16VehicleSpeedVld));
  SeatMemoryModule_DW.ResettableDelay_DSTATE[0] = gSMM_inU16DrvSeatCusQhHall;
  SeatMemoryModule_DW.ResettableDelay_DSTATE[1] = gSMM_inU16DrvSeatCusSzHall;
  SeatMemoryModule_DW.ResettableDelay_DSTATE[2] = gSMM_inU16DrvSeatBckQhHall;
  SeatMemoryModule_DW.ResettableDelay_DSTATE[3] = gSMM_inU16DrvMirrorQj1Hall;
  SeatMemoryModule_DW.ResettableDelay_DSTATE[4] = gSMM_inU16DrvMirrorQj2Hall;
  SeatMemoryModule_DW.ResettableDelay_DSTATE[5] = gSMM_inU16PssMirrorQj1Hall;
  SeatMemoryModule_DW.ResettableDelay_DSTATE[6] = gSMM_inU16PssMirrorQj2Hall;
  rtb_TmpSignalConversionAtSubs_g[0] = gSMM_inBlDrvSeatCusQhBlock;
  rtb_TmpSignalConversionAtSubs_g[1] = gSMM_inBlDrvSeatCusSzBlock;
  rtb_TmpSignalConversionAtSubs_g[2] = gSMM_inBlDrvSeatBckQhBlock;
  rtb_TmpSignalConversionAtSubs_g[3] = gSMM_inBlDrvMirrorQj1Block;
  rtb_TmpSignalConversionAtSubs_g[4] = gSMM_inBlDrvMirrorQj2Block;
  rtb_TmpSignalConversionAtSubs_g[5] = gSMM_inBlPssMirrorQj1Block;
  rtb_TmpSignalConversionAtSubs_g[6] = gSMM_inBlPssMirrorQj2Block;
  for (i = 0; i < 7; i++) {
    CurrAccount_prev = SeatMemoryModule_DW.CoreSubsys_pn[i].CurrAccount_start;
    SeatMemoryModule_DW.CoreSubsys_pn[i].CurrAccount_start =
      SeatMemoryModule_B.CurrAccount;
    if (SeatMemoryModule_DW.CoreSubsys_pn[i].is_active_c16_SeatMemoryModule ==
        0U) {
      SeatMemoryModule_DW.CoreSubsys_pn[i].is_active_c16_SeatMemoryModule = 1U;
      SeatMemoryModule_B.CoreSubsys_pn[i].AutoPosSts = 0U;
      SeatMemoryModule_DW.CoreSubsys_pn[i].is_c16_SeatMemoryModule =
        SeatMemoryModule_IN_Default_n;
      rtb_ImpAsg_InsertedFor_CtrlRe_c[i] = 0U;
    } else {
      guard1 = false;
      guard2 = false;
      switch (SeatMemoryModule_DW.CoreSubsys_pn[i].is_c16_SeatMemoryModule) {
       case SeatMemoryModule_IN_Default_n:
        rtb_ImpAsg_InsertedFor_CtrlRe_c[i] = 0U;
        if ((CurrAccount_prev != SeatMemoryModule_DW.CoreSubsys_pn[i].
             CurrAccount_start) && (rtb_TgtHall[i] >
             SeatMemoryModule_DW.ResettableDelay_DSTATE[i])) {
          SeatMemoryModule_DW.CoreSubsys_pn[i].is_c16_SeatMemoryModule =
            SeatMemoryModule_IN_MovBack;
          rtb_ImpAsg_InsertedFor_CtrlRe_c[i] = 2U;
          SeatMemoryModule_B.CoreSubsys_pn[i].AutoPosSts = 1U;
        } else {
          if ((CurrAccount_prev != SeatMemoryModule_DW.CoreSubsys_pn[i].
               CurrAccount_start) && (rtb_TgtHall[i] <
               SeatMemoryModule_DW.ResettableDelay_DSTATE[i])) {
            SeatMemoryModule_DW.CoreSubsys_pn[i].is_c16_SeatMemoryModule =
              SeatMemoryModule_IN_MovFrwd;
            rtb_ImpAsg_InsertedFor_CtrlRe_c[i] = 1U;
            SeatMemoryModule_B.CoreSubsys_pn[i].AutoPosSts = 1U;
          }
        }
        break;

       case SeatMemoryModule_IN_MovBack:
        rtb_ImpAsg_InsertedFor_CtrlRe_c[i] = 2U;
        if (rtb_TgtHall[i] <= SeatMemoryModule_DW.ResettableDelay_DSTATE[i]) {
          SeatMemoryModule_B.CoreSubsys_pn[i].AutoPosSts = 3U;
          guard2 = true;
        } else if ((CurrAccount_prev != SeatMemoryModule_DW.CoreSubsys_pn[i].
                    CurrAccount_start) && (rtb_TgtHall[i] <
                    SeatMemoryModule_DW.ResettableDelay_DSTATE[i])) {
          SeatMemoryModule_DW.CoreSubsys_pn[i].is_c16_SeatMemoryModule =
            SeatMemoryModule_IN_MovFrwd;
          rtb_ImpAsg_InsertedFor_CtrlRe_c[i] = 1U;
          SeatMemoryModule_B.CoreSubsys_pn[i].AutoPosSts = 1U;
        } else {
          if (rtb_Delete || rtb_TmpSignalConversionAtSubs_g[i]) {
            SeatMemoryModule_B.CoreSubsys_pn[i].AutoPosSts = 2U;
            guard2 = true;
          }
        }
        break;

       default:
        rtb_ImpAsg_InsertedFor_CtrlRe_c[i] = 1U;
        if (rtb_TgtHall[i] >= SeatMemoryModule_DW.ResettableDelay_DSTATE[i]) {
          SeatMemoryModule_B.CoreSubsys_pn[i].AutoPosSts = 3U;
          guard1 = true;
        } else if ((CurrAccount_prev != SeatMemoryModule_DW.CoreSubsys_pn[i].
                    CurrAccount_start) && (rtb_TgtHall[i] >
                    SeatMemoryModule_DW.ResettableDelay_DSTATE[i])) {
          SeatMemoryModule_DW.CoreSubsys_pn[i].is_c16_SeatMemoryModule =
            SeatMemoryModule_IN_MovBack;
          rtb_ImpAsg_InsertedFor_CtrlRe_c[i] = 2U;
          SeatMemoryModule_B.CoreSubsys_pn[i].AutoPosSts = 1U;
        } else {
          if (rtb_Delete || rtb_TmpSignalConversionAtSubs_g[i]) {
            SeatMemoryModule_B.CoreSubsys_pn[i].AutoPosSts = 2U;
            guard1 = true;
          }
        }
        break;
      }

      if (guard2) {
        SeatMemoryModule_DW.CoreSubsys_pn[i].is_c16_SeatMemoryModule =
          SeatMemoryModule_IN_Default_n;
        rtb_ImpAsg_InsertedFor_CtrlRe_c[i] = 0U;
      }

      if (guard1) {
        SeatMemoryModule_DW.CoreSubsys_pn[i].is_c16_SeatMemoryModule =
          SeatMemoryModule_IN_Default_n;
        rtb_ImpAsg_InsertedFor_CtrlRe_c[i] = 0U;
      }
    }

    rtb_ImpAsg_InsertedFor_AutoPosS[i] = SeatMemoryModule_B.CoreSubsys_pn[i].
      AutoPosSts;
    rtb_TmpSignalConversionAtSubs_g[i] = (SeatMemoryModule_B.CoreSubsys_pn[i].
      AutoPosSts == 3);
  }

  rtb_Delete = ((gSMM_inU8IGNSts == 2) && ((gSMM_inU16VehicleSpeed < 200) &&
    gSMM_inU16VehicleSpeedVld));
  rtb_LogicalOperator2_a = (rtb_LogicalOperator_nk || (gSMM_inU8CrashIntensity ==
    1) || ((gSMM_inU16VehicleSpeed > 200) && gSMM_inU16VehicleSpeedVld));
  tmp_2 = 41943U * gSMM_InU8DrvSeatCusQhValue;
  tmp_3 = gSMM_InU8DrvSeatCusQhMax;
  uMultiWordMul(&tmp_2, 1, &tmp_3, 1, &tmp_1.chunks[0U], 2);
  uMultiWordShr(&tmp_1.chunks[0U], 2, 22U, &tmp_0.chunks[0U], 2);
  rtb_DataTypeConversion[0] = (uint16_T)MultiWord2uLong(&tmp_0.chunks[0U]);
  tmp_2 = 41943U * gSMM_InU8DrvSeatCusSzValue;
  tmp_3 = gSMM_InU8DrvSeatCusSzMax;
  uMultiWordMul(&tmp_2, 1, &tmp_3, 1, &tmp_4.chunks[0U], 2);
  uMultiWordShr(&tmp_4.chunks[0U], 2, 22U, &tmp_1.chunks[0U], 2);
  rtb_DataTypeConversion[1] = (uint16_T)MultiWord2uLong(&tmp_1.chunks[0U]);
  tmp_2 = 41943U * gSMM_InU8DrvSeatBckQhValue;
  tmp_3 = gSMM_InU8DrvSeatBckQhMax;
  uMultiWordMul(&tmp_2, 1, &tmp_3, 1, &tmp_5.chunks[0U], 2);
  uMultiWordShr(&tmp_5.chunks[0U], 2, 22U, &tmp_4.chunks[0U], 2);
  rtb_DataTypeConversion[2] = (uint16_T)MultiWord2uLong(&tmp_4.chunks[0U]);
  rtb_TmpSignalConversionAtSubs_f[0] = gSMM_inU16DrvSeatCusQhHall;
  rtb_TmpSignalConversionAtSubs_f[1] = gSMM_inU16DrvSeatCusSzHall;
  rtb_TmpSignalConversionAtSubs_f[2] = gSMM_inU16DrvSeatBckQhHall;
  rtb_TmpSignalConversionAtSubs_h[0] = gSMM_inBlDrvSeatCusQhBlock;
  rtb_TmpSignalConversionAtSubs_h[1] = gSMM_inBlDrvSeatCusSzBlock;
  rtb_TmpSignalConversionAtSubs_h[2] = gSMM_inBlDrvSeatBckQhBlock;
  CurrAccount_prev_p = SeatMemoryModule_DW.CoreSubsys_pna[0].CurrAccount_start;
  SeatMemoryModule_DW.CoreSubsys_pna[0].CurrAccount_start = (rtb_Delete &&
    (rtb_DataTypeConversion[0] != SeatMemoryModule_DW.CoreSubsys_pna[0].
     DelayInput1_DSTATE));
  if (SeatMemoryModule_DW.CoreSubsys_pna[0].is_active_c17_SeatMemoryModule == 0U)
  {
    SeatMemoryModule_DW.CoreSubsys_pna[0].is_active_c17_SeatMemoryModule = 1U;
    SeatMemoryModule_DW.CoreSubsys_pna[0].is_c17_SeatMemoryModule =
      SeatMemoryModule_IN_Default_n;
    TmpSignalConversionAtAccount1_n[0] = 0U;
  } else {
    switch (SeatMemoryModule_DW.CoreSubsys_pna[0].is_c17_SeatMemoryModule) {
     case SeatMemoryModule_IN_Default_n:
      TmpSignalConversionAtAccount1_n[0] = 0U;
      if ((CurrAccount_prev_p != SeatMemoryModule_DW.CoreSubsys_pna[0].
           CurrAccount_start) && (rtb_DataTypeConversion[0] >
           rtb_TmpSignalConversionAtSubs_f[0])) {
        SeatMemoryModule_DW.CoreSubsys_pna[0].is_c17_SeatMemoryModule =
          SeatMemoryModule_IN_MovBack;
        TmpSignalConversionAtAccount1_n[0] = 2U;
      } else {
        if ((CurrAccount_prev_p != SeatMemoryModule_DW.CoreSubsys_pna[0].
             CurrAccount_start) && (rtb_DataTypeConversion[0] <
             rtb_TmpSignalConversionAtSubs_f[0])) {
          SeatMemoryModule_DW.CoreSubsys_pna[0].is_c17_SeatMemoryModule =
            SeatMemoryModule_IN_MovFrwd;
          TmpSignalConversionAtAccount1_n[0] = 1U;
        }
      }
      break;

     case SeatMemoryModule_IN_MovBack:
      TmpSignalConversionAtAccount1_n[0] = 2U;
      if ((rtb_DataTypeConversion[0] <= rtb_TmpSignalConversionAtSubs_f[0]) ||
          rtb_LogicalOperator2_a || rtb_TmpSignalConversionAtSubs_h[0]) {
        SeatMemoryModule_DW.CoreSubsys_pna[0].is_c17_SeatMemoryModule =
          SeatMemoryModule_IN_Default_n;
        TmpSignalConversionAtAccount1_n[0] = 0U;
      } else {
        if ((CurrAccount_prev_p != SeatMemoryModule_DW.CoreSubsys_pna[0].
             CurrAccount_start) && (rtb_DataTypeConversion[0] <
             rtb_TmpSignalConversionAtSubs_f[0])) {
          SeatMemoryModule_DW.CoreSubsys_pna[0].is_c17_SeatMemoryModule =
            SeatMemoryModule_IN_MovFrwd;
          TmpSignalConversionAtAccount1_n[0] = 1U;
        }
      }
      break;

     default:
      TmpSignalConversionAtAccount1_n[0] = 1U;
      if ((rtb_DataTypeConversion[0] >= rtb_TmpSignalConversionAtSubs_f[0]) ||
          rtb_LogicalOperator2_a || rtb_TmpSignalConversionAtSubs_h[0]) {
        SeatMemoryModule_DW.CoreSubsys_pna[0].is_c17_SeatMemoryModule =
          SeatMemoryModule_IN_Default_n;
        TmpSignalConversionAtAccount1_n[0] = 0U;
      } else {
        if ((CurrAccount_prev_p != SeatMemoryModule_DW.CoreSubsys_pna[0].
             CurrAccount_start) && (rtb_DataTypeConversion[0] >
             rtb_TmpSignalConversionAtSubs_f[0])) {
          SeatMemoryModule_DW.CoreSubsys_pna[0].is_c17_SeatMemoryModule =
            SeatMemoryModule_IN_MovBack;
          TmpSignalConversionAtAccount1_n[0] = 2U;
        }
      }
      break;
    }
  }

  SeatMemoryModule_DW.CoreSubsys_pna[0].DelayInput1_DSTATE =
    rtb_DataTypeConversion[0];
  CurrAccount_prev_p = SeatMemoryModule_DW.CoreSubsys_pna[1].CurrAccount_start;
  SeatMemoryModule_DW.CoreSubsys_pna[1].CurrAccount_start = (rtb_Delete &&
    (rtb_DataTypeConversion[1] != SeatMemoryModule_DW.CoreSubsys_pna[1].
     DelayInput1_DSTATE));
  if (SeatMemoryModule_DW.CoreSubsys_pna[1].is_active_c17_SeatMemoryModule == 0U)
  {
    SeatMemoryModule_DW.CoreSubsys_pna[1].is_active_c17_SeatMemoryModule = 1U;
    SeatMemoryModule_DW.CoreSubsys_pna[1].is_c17_SeatMemoryModule =
      SeatMemoryModule_IN_Default_n;
    TmpSignalConversionAtAccount1_n[1] = 0U;
  } else {
    switch (SeatMemoryModule_DW.CoreSubsys_pna[1].is_c17_SeatMemoryModule) {
     case SeatMemoryModule_IN_Default_n:
      TmpSignalConversionAtAccount1_n[1] = 0U;
      if ((CurrAccount_prev_p != SeatMemoryModule_DW.CoreSubsys_pna[1].
           CurrAccount_start) && (rtb_DataTypeConversion[1] >
           rtb_TmpSignalConversionAtSubs_f[1])) {
        SeatMemoryModule_DW.CoreSubsys_pna[1].is_c17_SeatMemoryModule =
          SeatMemoryModule_IN_MovBack;
        TmpSignalConversionAtAccount1_n[1] = 2U;
      } else {
        if ((CurrAccount_prev_p != SeatMemoryModule_DW.CoreSubsys_pna[1].
             CurrAccount_start) && (rtb_DataTypeConversion[1] <
             rtb_TmpSignalConversionAtSubs_f[1])) {
          SeatMemoryModule_DW.CoreSubsys_pna[1].is_c17_SeatMemoryModule =
            SeatMemoryModule_IN_MovFrwd;
          TmpSignalConversionAtAccount1_n[1] = 1U;
        }
      }
      break;

     case SeatMemoryModule_IN_MovBack:
      TmpSignalConversionAtAccount1_n[1] = 2U;
      if ((rtb_DataTypeConversion[1] <= rtb_TmpSignalConversionAtSubs_f[1]) ||
          rtb_LogicalOperator2_a || rtb_TmpSignalConversionAtSubs_h[1]) {
        SeatMemoryModule_DW.CoreSubsys_pna[1].is_c17_SeatMemoryModule =
          SeatMemoryModule_IN_Default_n;
        TmpSignalConversionAtAccount1_n[1] = 0U;
      } else {
        if ((CurrAccount_prev_p != SeatMemoryModule_DW.CoreSubsys_pna[1].
             CurrAccount_start) && (rtb_DataTypeConversion[1] <
             rtb_TmpSignalConversionAtSubs_f[1])) {
          SeatMemoryModule_DW.CoreSubsys_pna[1].is_c17_SeatMemoryModule =
            SeatMemoryModule_IN_MovFrwd;
          TmpSignalConversionAtAccount1_n[1] = 1U;
        }
      }
      break;

     default:
      TmpSignalConversionAtAccount1_n[1] = 1U;
      if ((rtb_DataTypeConversion[1] >= rtb_TmpSignalConversionAtSubs_f[1]) ||
          rtb_LogicalOperator2_a || rtb_TmpSignalConversionAtSubs_h[1]) {
        SeatMemoryModule_DW.CoreSubsys_pna[1].is_c17_SeatMemoryModule =
          SeatMemoryModule_IN_Default_n;
        TmpSignalConversionAtAccount1_n[1] = 0U;
      } else {
        if ((CurrAccount_prev_p != SeatMemoryModule_DW.CoreSubsys_pna[1].
             CurrAccount_start) && (rtb_DataTypeConversion[1] >
             rtb_TmpSignalConversionAtSubs_f[1])) {
          SeatMemoryModule_DW.CoreSubsys_pna[1].is_c17_SeatMemoryModule =
            SeatMemoryModule_IN_MovBack;
          TmpSignalConversionAtAccount1_n[1] = 2U;
        }
      }
      break;
    }
  }

  SeatMemoryModule_DW.CoreSubsys_pna[1].DelayInput1_DSTATE =
    rtb_DataTypeConversion[1];
  CurrAccount_prev_p = SeatMemoryModule_DW.CoreSubsys_pna[2].CurrAccount_start;
  SeatMemoryModule_DW.CoreSubsys_pna[2].CurrAccount_start = (rtb_Delete &&
    (rtb_DataTypeConversion[2] != SeatMemoryModule_DW.CoreSubsys_pna[2].
     DelayInput1_DSTATE));
  if (SeatMemoryModule_DW.CoreSubsys_pna[2].is_active_c17_SeatMemoryModule == 0U)
  {
    SeatMemoryModule_DW.CoreSubsys_pna[2].is_active_c17_SeatMemoryModule = 1U;
    SeatMemoryModule_DW.CoreSubsys_pna[2].is_c17_SeatMemoryModule =
      SeatMemoryModule_IN_Default_n;
    TmpSignalConversionAtAccount1_n[2] = 0U;
  } else {
    switch (SeatMemoryModule_DW.CoreSubsys_pna[2].is_c17_SeatMemoryModule) {
     case SeatMemoryModule_IN_Default_n:
      TmpSignalConversionAtAccount1_n[2] = 0U;
      if ((CurrAccount_prev_p != SeatMemoryModule_DW.CoreSubsys_pna[2].
           CurrAccount_start) && (rtb_DataTypeConversion[2] >
           rtb_TmpSignalConversionAtSubs_f[2])) {
        SeatMemoryModule_DW.CoreSubsys_pna[2].is_c17_SeatMemoryModule =
          SeatMemoryModule_IN_MovBack;
        TmpSignalConversionAtAccount1_n[2] = 2U;
      } else {
        if ((CurrAccount_prev_p != SeatMemoryModule_DW.CoreSubsys_pna[2].
             CurrAccount_start) && (rtb_DataTypeConversion[2] <
             rtb_TmpSignalConversionAtSubs_f[2])) {
          SeatMemoryModule_DW.CoreSubsys_pna[2].is_c17_SeatMemoryModule =
            SeatMemoryModule_IN_MovFrwd;
          TmpSignalConversionAtAccount1_n[2] = 1U;
        }
      }
      break;

     case SeatMemoryModule_IN_MovBack:
      TmpSignalConversionAtAccount1_n[2] = 2U;
      if ((rtb_DataTypeConversion[2] <= rtb_TmpSignalConversionAtSubs_f[2]) ||
          rtb_LogicalOperator2_a || rtb_TmpSignalConversionAtSubs_h[2]) {
        SeatMemoryModule_DW.CoreSubsys_pna[2].is_c17_SeatMemoryModule =
          SeatMemoryModule_IN_Default_n;
        TmpSignalConversionAtAccount1_n[2] = 0U;
      } else {
        if ((CurrAccount_prev_p != SeatMemoryModule_DW.CoreSubsys_pna[2].
             CurrAccount_start) && (rtb_DataTypeConversion[2] <
             rtb_TmpSignalConversionAtSubs_f[2])) {
          SeatMemoryModule_DW.CoreSubsys_pna[2].is_c17_SeatMemoryModule =
            SeatMemoryModule_IN_MovFrwd;
          TmpSignalConversionAtAccount1_n[2] = 1U;
        }
      }
      break;

     default:
      TmpSignalConversionAtAccount1_n[2] = 1U;
      if ((rtb_DataTypeConversion[2] >= rtb_TmpSignalConversionAtSubs_f[2]) ||
          rtb_LogicalOperator2_a || rtb_TmpSignalConversionAtSubs_h[2]) {
        SeatMemoryModule_DW.CoreSubsys_pna[2].is_c17_SeatMemoryModule =
          SeatMemoryModule_IN_Default_n;
        TmpSignalConversionAtAccount1_n[2] = 0U;
      } else {
        if ((CurrAccount_prev_p != SeatMemoryModule_DW.CoreSubsys_pna[2].
             CurrAccount_start) && (rtb_DataTypeConversion[2] >
             rtb_TmpSignalConversionAtSubs_f[2])) {
          SeatMemoryModule_DW.CoreSubsys_pna[2].is_c17_SeatMemoryModule =
            SeatMemoryModule_IN_MovBack;
          TmpSignalConversionAtAccount1_n[2] = 2U;
        }
      }
      break;
    }
  }

  SeatMemoryModule_DW.CoreSubsys_pna[2].DelayInput1_DSTATE =
    rtb_DataTypeConversion[2];
  rtb_LogicalOperator_nk = (rtb_LogicalOperator_nk || (gSMM_inU8CrashIntensity ==
    1) || ((gSMM_inU16VehicleSpeed > 200) && gSMM_inU16VehicleSpeedVld));
  rtb_Delete = SeatMemoryModule_DW.DrvDoorSts_start;
  SeatMemoryModule_DW.DrvDoorSts_start = gSMM_inBlDrvDoorSts;
  if (SeatMemoryModule_DW.is_active_c18_SeatMemoryModule == 0U) {
    SeatMemoryModule_DW.is_active_c18_SeatMemoryModule = 1U;
    SeatMemoryModule_DW.is_c18_SeatMemoryModule = SeatMemoryModule_IN_Default_n;
    SeatMemoryModule_B.SeatWelcomeReq = 0U;
  } else {
    switch (SeatMemoryModule_DW.is_c18_SeatMemoryModule) {
     case SeatMemoryModule_IN_Default_n:
      SeatMemoryModule_B.SeatWelcomeReq = 0U;
      if ((gSMM_inU8IGNSts == 0) && gSMM_inBlSeatWelcomeEn && ((rtb_Delete !=
            SeatMemoryModule_DW.DrvDoorSts_start) &&
           SeatMemoryModule_DW.DrvDoorSts_start)) {
        SeatMemoryModule_DW.is_c18_SeatMemoryModule =
          SeatMemoryModu_IN_WelcomeMvBack;
        SeatMemoryModule_DW.StartPos = gSMM_inU16DrvSeatCusQhHall;
        SeatMemoryModule_DW.is_WelcomeMvBack = SeatMemoryModule_IN_MoveBack;
        SeatMemoryModule_B.SeatWelcomeReq = 2U;
      }
      break;

     case SeatMemoryModu_IN_WelcomeMvBack:
      if (rtb_LogicalOperator_nk) {
        SeatMemoryModule_DW.is_WelcomeMvBack = SeatMemoryMo_IN_NO_ACTIVE_CHILD;
        SeatMemoryModule_DW.is_c18_SeatMemoryModule =
          SeatMemoryModule_IN_Default_n;
        SeatMemoryModule_B.SeatWelcomeReq = 0U;
      } else if (((rtb_Delete != SeatMemoryModule_DW.DrvDoorSts_start) &&
                  (!SeatMemoryModule_DW.DrvDoorSts_start)) || (gSMM_inU8IGNSts ==
                  2)) {
        SeatMemoryModule_DW.is_WelcomeMvBack = SeatMemoryMo_IN_NO_ACTIVE_CHILD;
        SeatMemoryModule_DW.is_c18_SeatMemoryModule =
          SeatMemoryModu_IN_WelcomeMvFrwd;
        SeatMemoryModule_DW.is_WelcomeMvFrwd = SeatMemoryModule_IN_MoveBack;
        SeatMemoryModule_B.SeatWelcomeReq = 1U;
      } else if (SeatMemoryModule_DW.is_WelcomeMvBack ==
                 SeatMemoryModule_IN_MoveBack) {
        SeatMemoryModule_B.SeatWelcomeReq = 2U;
        if ((gSMM_inU16DrvSeatCusQhHall - SeatMemoryModule_DW.StartPos >=
             gSMM_CfgU16SeatWelcomeHallCnt) || gSMM_inBlDrvSeatCusQhBlock) {
          SeatMemoryModule_DW.is_WelcomeMvBack = SeatMemoryModule_IN_MoveEnd;
          SeatMemoryModule_B.SeatWelcomeReq = 0U;
        }
      } else {
        SeatMemoryModule_B.SeatWelcomeReq = 0U;
      }
      break;

     default:
      if ((SeatMemoryModule_B.SeatWelcomeReq == 0) || rtb_LogicalOperator_nk) {
        SeatMemoryModule_DW.is_WelcomeMvFrwd = SeatMemoryMo_IN_NO_ACTIVE_CHILD;
        SeatMemoryModule_DW.is_c18_SeatMemoryModule =
          SeatMemoryModule_IN_Default_n;
        SeatMemoryModule_B.SeatWelcomeReq = 0U;
      } else if (SeatMemoryModule_DW.is_WelcomeMvFrwd ==
                 SeatMemoryModule_IN_MoveBack) {
        SeatMemoryModule_B.SeatWelcomeReq = 1U;
        if ((gSMM_inU16DrvSeatCusQhHall <= SeatMemoryModule_DW.StartPos) ||
            gSMM_inBlDrvSeatCusQhBlock) {
          SeatMemoryModule_DW.is_WelcomeMvFrwd = SeatMemoryModule_IN_MoveEnd;
          SeatMemoryModule_B.SeatWelcomeReq = 0U;
        }
      } else {
        SeatMemoryModule_B.SeatWelcomeReq = 0U;
      }
      break;
    }
  }

  if (gSMM_inU8IGNSts == 3) {
    for (i = 0; i < 7; i++) {
      rtb_Switch4_ii[i] = 0U;
    }
  } else {
    if (rtb_Compare_pu[0]) {
      rtb_Switch4_ii[0] = AccountApply_prev;
    } else if (TmpSignalConversionAtAccount1_n[0] != 0) {
      rtb_Switch4_ii[0] = TmpSignalConversionAtAccount1_n[0];
    } else if (rtb_ImpAsg_InsertedFor_CtrlRe_c[0] != 0) {
      rtb_Switch4_ii[0] = rtb_ImpAsg_InsertedFor_CtrlRe_c[0];
    } else if (SeatMemoryModule_B.SeatWelcomeReq != 0) {
      rtb_Switch4_ii[0] = SeatMemoryModule_B.SeatWelcomeReq;
    } else {
      rtb_Switch4_ii[0] = 0U;
    }

    if (rtb_Compare_pu[1]) {
      rtb_Switch4_ii[1] = rtb_Switch2;
    } else if (TmpSignalConversionAtAccount1_n[1] != 0) {
      rtb_Switch4_ii[1] = TmpSignalConversionAtAccount1_n[1];
    } else if (rtb_ImpAsg_InsertedFor_CtrlRe_c[1] != 0) {
      rtb_Switch4_ii[1] = rtb_ImpAsg_InsertedFor_CtrlRe_c[1];
    } else {
      rtb_Switch4_ii[1] = 0U;
    }

    if (rtb_Compare_pu[2]) {
      rtb_Switch4_ii[2] = rtb_Switch1_e;
    } else if (TmpSignalConversionAtAccount1_n[2] != 0) {
      rtb_Switch4_ii[2] = TmpSignalConversionAtAccount1_n[2];
    } else if (rtb_ImpAsg_InsertedFor_CtrlRe_c[2] != 0) {
      rtb_Switch4_ii[2] = rtb_ImpAsg_InsertedFor_CtrlRe_c[2];
    } else {
      rtb_Switch4_ii[2] = 0U;
    }

    if (rtb_Compare_pu[3]) {
      rtb_Switch4_ii[3] = rtb_Switch11;
    } else if (rtb_ImpAsg_InsertedFor_CtrlRe_c[3] != 0) {
      rtb_Switch4_ii[3] = rtb_ImpAsg_InsertedFor_CtrlRe_c[3];
    } else {
      rtb_Switch4_ii[3] = 0U;
    }

    if (rtb_Compare_pu[4]) {
      rtb_Switch4_ii[4] = rtb_Switch13;
    } else if (rtb_ImpAsg_InsertedFor_CtrlRe_c[4] != 0) {
      rtb_Switch4_ii[4] = rtb_ImpAsg_InsertedFor_CtrlRe_c[4];
    } else {
      rtb_Switch4_ii[4] = 0U;
    }

    if (rtb_Compare_pu[5]) {
      rtb_Switch4_ii[5] = rtb_Switch7_g;
    } else if (rtb_ImpAsg_InsertedFor_CtrlRe_c[5] != 0) {
      rtb_Switch4_ii[5] = rtb_ImpAsg_InsertedFor_CtrlRe_c[5];
    } else {
      rtb_Switch4_ii[5] = 0U;
    }

    if (rtb_Compare_pu[6]) {
      rtb_Switch4_ii[6] = rtb_Switch9_n;
    } else if (rtb_ImpAsg_InsertedFor_CtrlRe_c[6] != 0) {
      rtb_Switch4_ii[6] = rtb_ImpAsg_InsertedFor_CtrlRe_c[6];
    } else {
      rtb_Switch4_ii[6] = 0U;
    }
  }

  if (gSMM_InU8DrvSeatCusQhMax > 1) {
    i = gSMM_InU8DrvSeatCusQhMax;
  } else {
    i = 1;
  }

  if (gSMM_InU8DrvSeatCusSzMax > 1) {
    ForEach_itr_n0_0 = gSMM_InU8DrvSeatCusSzMax;
  } else {
    ForEach_itr_n0_0 = 1;
  }

  if (gSMM_InU8DrvSeatBckQhMax > 1) {
    ForEach_itr_n0 = gSMM_InU8DrvSeatBckQhMax;
  } else {
    ForEach_itr_n0 = 1;
  }

  gSMM_OutU8DrvSeatCusQhValue = (uint8_T)(((uint32_T)i == 0U ? MAX_uint32_T :
    51200U * gSMM_inU16DrvSeatCusQhHall / i) >> 9);
  gSMM_OutU8DrvSeatCusSzValue = (uint8_T)(((uint32_T)ForEach_itr_n0_0 == 0U ?
    MAX_uint32_T : 51200U * gSMM_inU16DrvSeatCusSzHall / ForEach_itr_n0_0) >> 9);
  gSMM_OutU8DrvSeatBckQhValue = (uint8_T)(((uint32_T)ForEach_itr_n0 == 0U ?
    MAX_uint32_T : 51200U * gSMM_inU16DrvSeatBckQhHall / ForEach_itr_n0) >> 9);
  gSMM_OutU8DrvSeatCusQhCmd = rtb_Switch4_ii[0];
  gSMM_OutU8DrvSeatCusSzCmd = rtb_Switch4_ii[1];
  gSMM_OutU8PssMirrorQj2Cmd = rtb_Switch4_ii[6];
  gSMM_OutU8DrvSeatBckQhCmd = rtb_Switch4_ii[2];
  gSMM_OutU8DrvMirrorQj1Cmd = rtb_Switch4_ii[3];
  gSMM_OutU8DrvMirrorQj2Cmd = rtb_Switch4_ii[4];
  gSMM_OutU8PssMirrorQj1Cmd = rtb_Switch4_ii[5];
  rtb_LogicalOperator_nk = rtb_TmpSignalConversionAtSubs_g[0];
  for (i = 0; i < 6; i++) {
    rtb_LogicalOperator_nk = (rtb_LogicalOperator_nk &&
      rtb_TmpSignalConversionAtSubs_g[i + 1]);
  }

  if (rtb_LogicalOperator_nk) {
    SeatMemoryModule_DW.UnitDelay1_DSTATE = 3U;
  } else {
    for (i = 0; i < 7; i++) {
      rtb_Compare_pu[i] = (rtb_ImpAsg_InsertedFor_AutoPosS[i] == 2);
    }

    rtb_LogicalOperator_nk = rtb_Compare_pu[0];
    for (i = 0; i < 6; i++) {
      rtb_LogicalOperator_nk = (rtb_LogicalOperator_nk || rtb_Compare_pu[i + 1]);
    }

    if (rtb_LogicalOperator_nk) {
      SeatMemoryModule_DW.UnitDelay1_DSTATE = 2U;
    } else {
      for (i = 0; i < 7; i++) {
        rtb_Compare_pu[i] = (rtb_ImpAsg_InsertedFor_AutoPosS[i] == 1);
      }

      rtb_LogicalOperator_nk = rtb_Compare_pu[0];
      for (i = 0; i < 6; i++) {
        rtb_LogicalOperator_nk = (rtb_LogicalOperator_nk && rtb_Compare_pu[i + 1]);
      }

      SeatMemoryModule_DW.UnitDelay1_DSTATE = rtb_LogicalOperator_nk;
    }
  }

  gSMM_OutU16Account1HallToEESw = rtb_ImpAsg_InsertedFor_Accoun_e[0];
  gSMM_OutU16Account2HallToEESw = rtb_ImpAsg_InsertedFor_Accoun_e[1];
  gSMM_OutU16Account3HallToEESw = rtb_ImpAsg_InsertedFor_Accoun_e[2];
  SeatMemoryModule_DW.icLoad = 0U;
  if (!gSMM_OutU16Account0HallToEESw) {
    for (i = 0; i < 7; i++) {
      SeatMemoryModule_DW.ResettableDelay_DSTATE[i] =
        gSMM_OutU16Account0HallToEE[i];
    }
  }

  SeatMemoryModule_DW.UnitDelay_DSTATE = SeatMemoryModule_B.CurrAccount;
}

void SeatMemoryModule_initialize(void)
{
  SeatMemoryModule_DW.icLoad = 1U;
  SeatMemoryModule_DW.CoreSubsys_p[0].icLoad = 1U;
  SeatMemoryModule_DW.CoreSubsys_p[1].icLoad = 1U;
  SeatMemoryModule_DW.CoreSubsys_p[2].icLoad = 1U;
}

void SeatMemoryModule_terminate(void)
{
}
